PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
require('db_connect.php');
$db_object->setFetchMode(DB_FETCHMODE_ASSOC);
$result = mysql_query( "SELECT on_sale FROM productinfo" )
or die("SELECT Error: ".mysql_error());
$result1 = mysql_query( "SELECT product_image FROM productinfo" )
or die("SELECT Error: ".mysql_error());
echo "<table border=\"1\">";
while ($get_query = mysql_fetch_row($result)){
while ($get_query1 = mysql_fetch_row($result1)){
echo "<tr>";
foreach ($get_query as $rows){
foreach ($get_query1 as $rows1){
if ($rows == 1) {
echo "<td>$rows1</td>";
}
}
}
}
echo "</tr>";
}
echo "</table>";
$db_object->disconnect();
?>
i cant seem to figure out why this wont work i am trying to compare two rows in my data base like......example my tables values are 'john' 'jane'
cool 1
nice 0
how do i make so that if jane=1 then echo cool then go to the next row and check the same thing??
you'll need to either use a seek() to get back to the initial record in the inner loop, or (recommended) you cache the results of the inner loop first into an array which you can endlessly loop over without much issue (RAM providing)
The second, to cache the data you create a loop, just like any other mysql result set loop, but save each record into an array. I couldn't find an example quickly, so here's the basic idea behind caching: