cyberangel Posted October 6, 2008 Share Posted October 6, 2008 hi all, am back again with a problem, and i hope i will get wonderfull help here once again. what i am actually trying to do is that i have a .csv file wich is supposed to contain information for different room numbers. for example a list of clean and dirty rooms. i wanted to get a php script which can find the room in the list and display only that row. i found a script which works and displays all the rooms list, which is not what i need. the script is as follows: <?php $row = 1; $handle = fopen ("test.csv","r"); while ($data = fgetcsv ($handle, 1000, ",")) { $num = count ($data); print "<p> $num fields in line $row: <br>\n"; $row++; for ($c=0; $c < $num; $c++) { print $data[$c] . "<br>\n"; } } fclose ($handle); ?> it actually displays the complete csv file. i am using certian php scripts with mysql, where i have a form page with just 1 or 2 text boxes, it posts the variables to the second page which finds the data in mysql database and displays the result. i want the same to happen with csv file. can anybody please help me? many thanks in advance Quote Link to comment Share on other sites More sharing options...
Barand Posted October 6, 2008 Share Posted October 6, 2008 inside the while loop, where N is the col number containing the room number and $room_number is the room you want to print if ($data[N] == $room_number) { // code to print data } Quote Link to comment Share on other sites More sharing options...
cyberangel Posted October 7, 2008 Author Share Posted October 7, 2008 hi barand, thanks for the reply. i didn't write the code myself, i just found it in internet so i tried to add your code to the while loop somehow. I couldn't actually figure out how to add it. all i need is to print the room number and status of the room. for example, i want to see if the room number 110 is clean or dirty, i type 110 in the form text field in first page, it reads the csv file which includes the info and shows 110 - clean or 110 - dirty. i know i should learn more myself to get it done but will appreciate any help. Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.