Jump to content

Loop Issue


Php_Ghost

Recommended Posts

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. 8)

 

 

<?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>";
}
}
}
}
?> 

 

 

Link to comment
https://forums.phpfreaks.com/topic/203495-loop-issue/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.