I am running repeated while() statements using mysql_query. However, I have noticed that only the first while() statement works. All the others don't show up unless I repeat the query just above the while().
Ex:
This does NOT work:
$qdata = mysql_query("SELECT * FROM data_ww2 WHERE model = '$model'", $conn);
echo "<table cellspacing=\"0\" cellpadding=\"0\" class=\"data_tab\">
<tr class=\"data_toprow\">
<td class=\"data_list\"></td>\n";
while($data = mysql_fetch_array($qdata)) { echo "<td class=\"data_top\"><img src=\"" . $img . "sflag_" . $data['country'] . ".gif\"></td> \n"; };
echo " </tr>
<tr>
<td class=\"data_list\">Design</td>";
while($data = mysql_fetch_array($qdata)) { echo "<td class=\"data_bold\">" . $data['design'] . "</td> \n"; };
echo " </tr>
<tr>
<td class=\"data_list\">Name</td>";
while($data = mysql_fetch_array($qdata)) { echo "<td class=\"data_bold\">" . $data['name'] . "</td> \n"; };
This DOES work
echo "<table cellspacing=\"0\" cellpadding=\"0\" class=\"data_tab\">
<tr class=\"data_toprow\">
<td class=\"data_list\"></td>\n";
$qdata = mysql_query("SELECT * FROM data_ww2 WHERE model = '$model'", $conn);
while($data = mysql_fetch_array($qdata)) {
echo "<td class=\"data_top\"><img src=\"" . $img . "sflag_" . $data['country'] . ".gif\"></td> \n"; };
echo " </tr>
<tr>
<td class=\"data_list\">Design</td>";
$qdata = mysql_query("SELECT * FROM data_ww2 WHERE model = '$model'", $conn);
while($data = mysql_fetch_array($qdata)) { echo "<td class=\"data_bold\">" . $data['design'] . "</td> \n"; };
echo " </tr>
<tr>
<td class=\"data_list\">Name</td>";
$qdata = mysql_query("SELECT * FROM data_ww2 WHERE model = '$model'", $conn);
while($data = mysql_fetch_array($qdata)) { echo "<td class=\"data_bold\">" . $data['name'] . "</td> \n"; };
My question is whether it is always necessary to repeat the mysql_query() above every while() loop even though its the exact same query instead of having every while() loop reference that same query.
Thanks.