Getting Specific Fields From A CSV
I've been using fgetcsv to populate an HTML table with CSV data and so far it has been working great. But now I'm looking to call specific data from the table (ie: row 3, column 5), and I'm not sure fgetcsv can be used for this. Every online example of its use involves getting all the CSV data from a file as my table has done.
What function should I use to get specific fields from my CSV? My table doesn't use unique ids, at least not like mysql, with a unique number identifying each row in the leftmost column. What then should I use to identify each row from which I'd like to get data?
I'm making a page that describes a person based on the query string and the information in the database, in which each person has a row. So example.com/example.php?christopher+walken would bring up a page where Walken's information is listed. So I guess the ideal way to do what I want is to query the CSV for the name in the query string (Christopher Walken), then get and print the other information in the row (tall, great guy, etc). Any suggestions on this query?
View Complete Forum Thread with Replies
Related Forum Messages:
Specific Fields In FFD
I have a flat file database with data like the following: Code: 01|Greg|5 02|John|1 02|John|5 03|Mary|3 04|Matt|2 02|John|3 with the form being ID|Name|Hours. How can I extract just, for instance, John's hours and show that he has worked 9 hours total (1 + 5 + 3)? I have found from various sites how to display a single person's information.
View Replies !
Echo To A Specific Div On A Specific Page
Is it possible to echo something from a php file to a specific div in a different specific html file?If so, can you let me know how to specify where the data should displayed. $myName="john"; echo '$myName'//but i want to echo to a different page on a certain part of that page.
View Replies !
Sending People To Specific Pages That Are Coming From Specific Pages...
I want to show some specific pages to people that comes to my site from specific urls, I know the variable $_SERVER['HTTP_REFERER'] will be used but how? For ex if the visitor comes from a site that is like: I want to send this person a specific.php . I used below code but not worked: <?php if($_SERVER['HTTP_REFERER'] == "www.cominghost.com" || $_SERVER['HTTP_REFERER'] == "cominghost.com" || $_SERVER['HTTP_REFERER'] == "www2.cominghost.com"){ // Specific page html goes here } else { header("Location: index.php"); } ?> This code not worked for some cases like if the visitor comes from http://www.cominghost.com/account/targeturl.php or http://cominghost.com/account/targeturl.php Ok I know the if statement not working but How?
View Replies !
Multiple Fields - How To Select 3 Rows's Fields
is there a code example on how to select 3 rows's fields. lets say. there is a same user id - but has 3 different rows with different values which came from name,middle name and last name which came from 3 different forms and i want to pull them all out in one query from db then use it as a new value for another table's row field.
View Replies !
Specific IF/Then...
I have a code that displays a value from a row in a mysql db. The code is this: echo "<td>" . $row['year'] . "</td>"; When the user submits their information, there is an option that says "hide the year I was born." Since the row for "year" is set it INT, if they choose that option it returns "0." I was wondering if there was a way to do something like if $row['year'] = "0"{ echo"hidden by request" } else{ echo "<td>" . $row['year'] . "</td>"; } but still have it work with my existing code.
View Replies !
How To Add An SPECIFIC Array
sorry if the subject isint really good to understand, now i will try to explain my best. I recently installed a hack in phpbb and that particular hack allows only 1 variable, but i want to add more than one, and i thought the best thing to do it is in an ARRAY, but i dont know how to do it in an array, the code looks something like this:
View Replies !
How To Redirect With Specific Value ..?
I want that when i recieve different values from "form page" i will mail myself all the details and redirect the user to another site for CR Card payment. What i need is redirect the user to another site along with the value of total amount of package .How can I do that. I have done the first part of mailing but dont know how to do the redirection in PHP ..
View Replies !
Selecting Specific Tag
I am making a script which displays an RSS feed on my website. To do this I would like to take all the <div class="blabla"><img src="bla.jpg" alt="bla"> </div> tags and put them in front of my text. So the following string: <p>This is text blah blah blah</p> <div class="blabla"><img src="bla.jpg" alt="bla"> </div> <p>this is another text</p> should give as output: <div class="blabla"><img src="bla.jpg" alt="bla"> </div> <p>This is text blah blah blah</p> <p>this is another text</p> I tried using regular expressions, but I do not really get it done. Here is the code I use: while(ereg('/<DIV class="blabla"*>(.*?)</DIV>/i',$content, $matches)){ $img=$img.$matches[0]; $content=ereg_replace('/<DIV class="imgbar50"*>(.*?)</DIV>/i',"",$content,1); } what do i do wrong?
View Replies !
PHP Editor, Vim Specific.
Does anyone have a really good php indent file for vim? I'm working on my first really sizeable project and I'd like it to be kept as clean as possible while I'm working.
View Replies !
Specific Record From DB
I have a form which updates customer information and as default this gets started on record 1. I would like to be able to post a clientname from a previous form and then get the specific data for that customer. I am fine with the posting to seperate pages stuff but how could I get the update form to start on this record? Code:
View Replies !
Specific Pagination !
I've got some regular joe schmoe queries running ... now the totally result of these queries goes well over 2,000 records. Im looking to paginate these in a certain fashion : << Prev 1 2 3 4 5 6 7 8 9 10 Next >> Each # obviously will display the page ! but Prev and Next will jump to either previous 10 or next 10... so if im on page 4 and i hit next ! i dont want to go to page 5 but rather page 11 and display: << Prev 11 12 13 14 15 16 17 18 19 20 Next >> I hope this is doable ! if not please give me a better suggestion, a more effective and/or efficient way to be able to browse through all these records.
View Replies !
Specific Lines
I have the text file 'text.txt' and the contents of it are: CodingForums.com is not cool and i want to change only the 2nd line so the contents of text file is: CodingForums.com is very cool how would I do that? also how would I read just the 1st line?the contents text file would be: CodingForums.com is very cool
View Replies !
Specific Characters
i want to match some specific character set 10 odd characters in a user input string. i want to find all occurences of the any of such characters. i am using preg_match_all for this.the string pattern that i am giving is a regular expression having those characters i.e "ch1|ch2|ch3" but i am getting only first occurence of the the char which is there in the regular expression. where i am goin wrong and how can capture all occurences of those chars. e.g pattern- "x|y|z" string to search "this is the X string for test Z and Y are at end and are not detected" in above case the character that is matched is only X at 13th position and z and y are not matched. i want to detect presence of all 3 chars. i.e x,y as well as z. how can i achieve this.
View Replies !
Specific Include
I have read a lot of posts about the include statement and understand the majority but there is one small thing missing for me. Maybe you could help enlighten me. I read that I can include htm files or php files. Therefore I have two senarios. 1. If I include using a htm within a htm page, how much do I need to write in that htm file that will be included. Code:
View Replies !
Go To Specific Page
I have a search box, then I put in search criteria, got a returned result. When I click on to view that result, I got a page that says "you have to login first". After I login, I want my page to go to that "result page" instead of the member page. Is there a way to do that?
View Replies !
Getting Specific User
I have my login script, and I have it setup so that if they are not logged in it shows the login box, and if they are, it shows a welcome message. But how I can I get the specific username of the person who logged in, from the database? Here is my code: <?php if (!isset($_SESSION['authenticated'])) { echo "<form id="form1" name="form1" method="post" action=""> <label for="username">Username:</label> <input type="text" name="username" id="username" /> <label for="textfield">Password</label> <input type="password" name="pwd" id="pwd" /> <input name="login" type="image" src="images/login_button.jpg" id="login" value="Log in" /> </form>"; exit; } echo "Hey, welcome back $username!"; ?>
View Replies !
Get Specific Query
theres a set of links that derive from a database when a link is clicked you are fowarded to a page called list.php in this page i want to get certain information out of the database based on what link is clicked so this is how it works PHP Code:
View Replies !
Delete A Specific Row
How can i delete a specific row from a mySQL table. I want to delete Image2 (or make the value of it is nothing, NULL) <?php $con = mysql_connect("localhost","name","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("npsari_other", $con); mysql_query("DELETE Image2 FROM ads WHERE ID='$ID'"); mysql_close($con); ?> Is this code right, because it doesnt work.
View Replies !
Specific Types
Is there anyway to count just the. jpg files in a directory? Right now I am counting all the files, but there are some file types I don't want to count.
View Replies !
Specific Variables
hi i was wondering how to count specific variables in an sql database and have it echo the count in a php script. below is what i have so far. PHP Code: $query = "SELECT * FROM ibf_members WHERE mgroup"; $result = mysql_query($query) or die("Query Ruter failed"); while ($row = mysql_fetch_array($result));
View Replies !
Rows With Specific Ids
I have many rows in my database, all with ids which are not unique. I would like to count these ids and display the numbers in a loop. Like so. Row 1 (67) Row 2 (34) Row 3 (234) All ids that match the id of the row should be counted and displayed. I have tried this. $count = mysql_result(mysql_query("SELECT COUNT(*) FROM table WHERE $id=id"), 0);
View Replies !
Returning Specific
I'm new to PHP. I have a properties database (MYSQL). When I click on a specific link, the results show all the properties in the database, however what I need the results to show is not all the properties but ones that meet a certain criteria. I want it to show the ones that are listed as "Rentals" only.
View Replies !
Specific Truncating
I have a block of text stored in a variable, it's order data so it's always different. It's data that is sent back to me as is, so I can't get at what makes it up. I'm trying to get the IP address from the middle of this block of text isolated and put into a variable. The IP always follows the words IP Address:
View Replies !
Looking For A Specific Script
I need to find a script that will allow users to submit their URL to my site and be displayed in a column. Along with that I would like it to have a hit counter to show how many times that link has been clicked. A good example of what I would like is on this site. http://www.lookom.com/. On the righthand side of the page is what I would like.
View Replies !
Specific Calender
I'm a designer by trade so PHP can sometimes be a little out of my comfort zone, but thats always a good place to be, right? I have a specific and I should imagine very easy thing i need to set up. I'm making a website for a band who play a lot of live shows. I wonder if anyone has the best solution to make a list of their shows that automatically deletes a show once it's date has passed. You know the way, say, the Myspace live list works. I don't need any fancy calender graphics or anything like that. Just a self-updating list.
View Replies !
How To Write IE Specific
I have a small peice of code that i want to append as a attribute to a html element ONLY if the users browser is IE. I know how to detect the browser in JS, however i have yet to find an easy way to detect IE in php Code:
View Replies !
$http_referrer Allow Access From Specific URL Only
I am trying to figure out the correct PHP coding to put on a page that will only allow access if referred by a specific URL or URLs (link from another site) and if they are not c oming from that URL(s) then they are redirected to somewhere else like yahoo, etc.
View Replies !
Targeting Specific Frame
Hi I have used frames a while ago but not since going with PHP Is there anything special with frames and PHP I seem to be having trouble with targeting a different frame I have 3 frameset "top", "side" and "main" in the side frame I grab some info from a database and create a simple anchor tag with some variables loaded into into and I want to when the anchor tag is clicked have the information loaded into the "main" frame. the link does not appear to be created correctly here is the actual code for the anchor tag.
View Replies !
Search Question - How To Get Specific
I have a search script on my site now using LIKE with wildcards on either side. The problem is that if someone searches on "APHS" which is a type of film, anything with the word photogrAPHS comes up too. Obviously because the pattern matches. However if I take off the wildcards it wont find it because its not the first word of the string. Anyone have anything thoughts on how to go about that? So that if you search on APHS is searches the whole field to see if there is a word match?
View Replies !
Destroying A Specific Session?
how to destroy the server-side data associated with a session *after* session_write_close() has been called? session_destroy() won't work after session_write_close() because there is no currently-initialized session, and the manual doesn't indicate that there's any way of telling session_destroy() to destroy the data associated with a specific sessionid, which is the only route I could think of to make this work. Calling session_start() to initialize the session a second time (in preparation for a call to session_destroy()) isn't an option, because headers have already been sent by the script.
View Replies !
Find A Specific Value In An Array
What I want to do is compare a value against an array and perform a specified action if the value is in the array. Specifically, I want to preselect an option in a list based on whether or not the option id is in a field (a 'set' column) of a specific entry in a db. My code so far is: PHP Code:
View Replies !
Getting Data From A Specific Row With Mysql
I'm makin a member's area on my site with sessions, as they log in correctly the username is stored as $_SESSION['user'] what I can't work out, is how to access my table and extract data from just the row that has that username, eg SELECT * FROM table WHERE username=$_SESSION['user'] as I'm trying to make the users be able to edit profile, upload pics etc... any idea what I'm doing wrong?
View Replies !
Upload To Specific Folder
I am working in a directory: /www/domain/ and made the directory /www/domain/images/ What I need is for people to be able to upload images to this folder from a form on upload.php They should click browse and select their file to upload then press the "Upload" button. On the next page I want to display the .jpg or .gif that they uploaded. What is the coding for uploading that should go into the first upload.php script and the coding for the upload_result.php script. I think that the result could be: echo "<img src="images/$file">"; where $file = the image they uploaded. But I cannot seem to figure out what the first code should be.
View Replies !
Connection Specific Question
Whenever the PHP documentation references the optional link_identifier parameter in many mysql related functions (such as mysql_query, mysql_insert_id, etc.), it says: "The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If by chance no connection is found or established, an E_WARNING level warning is generated." I know that functions such as mysql_insert_id are connection specific, but I have not been able to find any info explicitly stating that it is also connection specific when link_identifier is omitted. I am about 99% sure that it would still be connection specific because otherwise these functions would be pretty useless, but could someone please confirm this? I just want to avoid the scenario where persons A and B are accessing the same script, but by the time person A runs mysql_insert_id (or some other mysql function), person B's connection is technically "the last link opened by mysql_connect()". In other words, I want to make sure that I can omit the link_identifier and still be confident that different connections will not affect each other.
View Replies !
Convert To PNG Using A Specific Palette?
I'm doing a site that has more than one interface/skins. Apart from the standard truecolor skin I have a 2 color b/w, 16 and 32 colors options. The problem is when I'm adding new graphical content - the thumbnails will always stand out because they are truecolor. Is there a way to convert to multiple files having different user specified palettes using GDLIB? Using the imagepalettecopy function seems to have no effect. I tried using it on 24bit png => 8bit indexed png and 8bit index png => 2bit index png. PHP Code:
View Replies !
PHP-4.3.2 Specific Safe_mode Problem
I am having a problem with safe_mode in PHP-4.3.2. I was running an Apache-1.3.27 web server on solaris8 with PHP-4.3.1 with safe_mode on - and everything was working fine. Yesterday, I upgraded to Apache-1.3.28 and PHP-4.3.2 with the same settings as before - but safe_mode was acting strange. A script with a specific group was not allowed to access another file with the same group - and safe_mode_gid is on. The error log says the following: "PHP Warning: fopen(): SAFE MODE Restriction in effect. The script whose uid/gid is 1/7177 is not allowed to access menu.txt owned by uid/gid 7742/10 in ..." But those UID/GID are the wrong ones. They do in fact match the file. After hours of trying to figure out the problem, I decided to replace the present PHP-4.3.2 with PHP-4.3.1 with the exact same settings. And it worked. Am I the only one with that problem?
View Replies !
Rtrim() A Specific String
Is it possible to trim a specific string of characters from the end of an existing string? I know you can use rtrim() to strip characters off, but rtrim() reads a character, one at a time, comparing it to the end of the string. I want to eliminate an entire string (and ONLY that string) from the end of the string in question. Example: I have a string that looks like this: 2:E,9,4:B+C,5-D,6:C+G&D,12:0+E,8:E I want to trim ,9,4:B+C,5-D,6:C+G&D,12:0+E,8:E off the end so that it leaves only 2:E. However, if I did rtrim($string,',9,4:B+C,5-D,6:C+G&D,12:0+E,8:E'); It would eat up everything, because "2," ":," and "E," are all contained in the trim parameters. Does that make sense? I'm basically looking for a literal trim kind of function.
View Replies !
Replacing A Specific <a Href ... </a>
I've been coding in PHP for a little while now and was starting to feel pretty confident but then realise I need to understand regular expressions to solve a particular problem I've got ... What a horrible can of worms regex is!! (to the uninitiated at least). I realise that if I spend the next few weeks researching regex I'll probably find the answer but I was wondering if anyone here would kindly help speed up the process? Basically I am grabbing the html from another URL, finding a specific <a href .. </a> block and replacing the contents of that block with another link. (n.b. the code examples below are pseudo code - I realise I need to 'escape' some characters) Here's how I'm grabbing the source html : $html = join ("", file (http://www.sitexyz.com/index.htm)); the link I want to replace looks something like : <a href="http://www.sitexyz.com/page2"><img height="120" src="origpic.jpg"></a> Note - the only thing I know to be constant about the above link is that the height is always 120 - the link destination and source image are completely unpredictable. Here's a variable holding the replacement link to my site using a different image : $newlink = "<a href="http://www.mysite.com"><img height="120" src="mypic.jpg"></a>"; So... how do I use preg_replace() or ereg_replace() to find the <a href .. </a> block encompassing an image of height 120 and replace it with the contents of my $newlink variable? *** To precis my question ... How do I replace an HTML link (where all I know is the image height) with a link of my own? ***
View Replies !
Destroy A Specific Session
How do you destroy a specific session without damaging the others: <?php $id = $_SESSION['id']; $username = $_SESSION['username']; $password = $_SESSION['password'];?> How could i just destroy $id = $_SESSION['id']; ?
View Replies !
Search A Row Rather Than A Specific Column?
Heres the situation, my client wants a search facility on the site. I can do this OK, but the problem that I am finding is that as I am searching a database, I have to type every single field in. eg "SELECT * FROM table WHERE name LIKE '%$search%' OR comment LIKE '%$search%'"; However, there are 25 fields on this table, and many more thousands on the other tables, so is it possible to search a row rather than a specific column?
View Replies !
Output Specific Row Data
I've got a standard web page outputting data about a client. one side lists all the contacts for the company that I'm doing with a standard repeat region. I'd like to output a specific row to a different section of the page, but not sure how to call a specific row (i.e. row 1,2 and 3).
View Replies !
Stopping Specific Strings (.jpg Etc)
How can i make it so that only if .jpg etc is stopped, as the word jpg etc is being stopped, i tried adding dots before each word in the array, but this made no difference. if (eregi("jpg|jpeg|gif|bmp|png", $weburl)) { die ("Your website url can not be an image."); }
View Replies !
Capture A Specific String
I have a data and i put it all together inside a variable called DATA, this is what inside of $DATA after i gather all the data that i needed. $DATA = " copyright of me and you 2007 and the others bread 15.22 44.97% crumbs 15.532 6.47% apple 146.932 6.555% coffe 83.72 6.537% thank you all friend and everyone data date and year 2007 "; i need to only capture this data and remove the others: bread 15.22 44.97% crumbs 15.532 6.47% apple 146.932 6.555% coffe 83.72 6.537% and split it and make each data inside another variable, like this : $a = bread 15.22 44.97% $b = crumbs 15.532 6.47% $c = apple 146.932 6.555% $d = coffe 83.72 6.537% can this be done? and also the data that i try to capture is random, but always with this type : letter - number - number like bread - 15.22 - 44.97% .
View Replies !
Counting A Specific Id To Display
i have constructed a forum (very basic) i have 2 main categories , 1 has id 1 and the other 2. once a topic is posted within these categories a 1 or a 2 is stored into `topic_id` which is in `forum_topics` so if i post in category 1, a 1 is stored into `forum_topics` as a way of tracking the different categories that are added later, my problem is when i put my pagination in for the sections, (it displays the correct number of links for each section) but still shows me all the posts, the links are right but it still displays the posts on the 1 page Code:
View Replies !
Hide Specific Text
I was wondering whteher anybody knows a code to hide a specific text on a site which u cannot control. For Example, i am currently with a free hosting provider, and they put a simple text on my site saying "Free Web Hosting by something" Is there a way to hide this?. It is not on my actual coding for the page therefore i cannot remove it. I thought there might be a way to block this text or something. It can be a code of any sort like php, html, asp or whatever. I just need to hide this.
View Replies !
|