Php_Ghost Posted June 1, 2010 Share Posted June 1, 2010 Hi I am trying to make search php script. i got tables where is list of game names and links. But by applying this code it retrieving the list but giving same hyper link to all 7 Game Name. I think may it is due to loops, may i know how can I fix this. Thank you. <?php $name = $_POST['name']; $db = mysql_connect("localhost","); mysql_select_db ("master",$db); $query = "SELECT GameName FROM Game WHERE GameName LIKE '%".$name."%'limit 1"; $result = mysql_query($query); while ($record = mysql_fetch_assoc($result)){ while (list ($FieldName, $FieldValue) = each ($record)){ $query2 = "SELECT link FROM Movie WHERE GameName LIKE '%".$name."%'"; $result2 = mysql_query($query2); while ($record2 = mysql_fetch_row($result2)){ while (list ($FieldName2, $FieldValue2) = each ($record2)){ echo "<A HREF ='".$FieldValue2."'>".$FieldValue."<BR>"; } } } } ?> Quote Link to comment Share on other sites More sharing options...
riwan Posted June 1, 2010 Share Posted June 1, 2010 may I know why you do the query for table game ? you could just use query for this $query2 = "SELECT GameName,link FROM Movie WHERE GameName LIKE '%".$name."%'"; 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.