phpnb Posted October 16, 2006 Share Posted October 16, 2006 hi everyone, am new here, new to php as wellhave a question as i am baffled. i have been on this for a while but still searching for an answer.heres the logicim getting user input through a text box and storing it in a variableim searching through a text file for a match and displaying the output. The text file holds data about cars. if the user enters lets say model then it should display the make, model, price, year, viewed values. i have got it to store the values in array form.<html><head><title> Maximum Price </title></head><BODY bgcolor=white vlink=white><FORM NAME=myForm METHOD="POST" >Maximum Price <INPUT SIZE =12 TYPE="text" name="Numb1"><INPUT TYPE="SUBMIT" VALUE="Process"><p><?$filename = "cars.txt";$fd = fopen ($filename, "r");$contents = fread ($fd,filesize ($filename));fclose ($fd);$splitcontents = explode(",", $contents);#The following part stores make, model, price, year, viewed in array form, eg table[0], table[1]#table[0] holds 1 record, table[1] holds another record and so on##############$check=0;$nc=9;for ($count=5; $count<count($splitcontents); $count++) { $table[$check][]=$splitcontents[$count]; if ($count==$nc){ $nc+=5; $check+=1; }}##############################################$val = $_POST['Numb1'];## as an example i was trying to display value from table[0] only but even that didnt workfor ($count=0; $count<count($table[0]); $count++){ if($val==$table[0][$count]){ #if the value returned matches with for ($nc=0; $nc<count($table[0]); $nc++){ #any value from table[0] then print out the print $table[0][$nc]; #the whole table } }}###########really need help guyswill wait for positive replies.thanks all Quote Link to comment Share on other sites More sharing options...
btherl Posted October 16, 2006 Share Posted October 16, 2006 If I was debugging that, I would add var_dump($table) inside the loop where you create $table. That will show you what is happening. If that doesn't help, add var_dump($table[0]) before you try to print out $table[0]. The results should help you solve your problem :) 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.