This code belongs to a shopping cart which I want to print multiple times with the help of a loop.
There are 9 SQL queries and I want all these queries to run at a time with the below table every time the SQL query changes, but the below table remains the same.
//SQL query define in array
$query = array(
"SELECT * FROM products WHERE rowno=1
and colno=1 and pageno=1 and productLine like '$cat'",
"SELECT * FROM products WHERE rowno=1 and colno=2
and pageno=1 and productLine like '$cat'",
"SELECT * FROM products WHERE rowno=1 and colno=3
and pageno=1 and productLine like '$cat'",
"SELECT * FROM products WHERE rowno=2 and colno=1 and pageno=1
and productLine like '$cat'",
"SELECT * FROM products WHERE rowno=2 and colno=2
and pageno=1 and productLine like '$cat'",
"SELECT * FROM products WHERE rowno=2 and colno=3
and pageno=1 and productLine like '$cat'",
"SELECT * FROM products WHERE rowno=3 and colno=1
and pageno=1 and productLine like '$cat'",
"SELECT * FROM products WHERE rowno=3 and colno=2
and pageno=1 and productLine like '$cat'",
"SELECT * FROM products WHERE rowno=3 and colno=3
and pageno=1 and productLine like '$cat'");
foreach($query as $a)
{
$cmd=mysql_query($query,$conn); // con query
$row=mysql_fetch_row($cmd); // fetch the table in database
echo
"<tr>
<td>$row[1]</td> // table row
</tr>
<tr>
<td><img alt='' src='$row[9]' style='height: 151px; width: 214px' />
</td>
</tr>
<tr>
<td>
RS $row[7] </td> // this table same in loop but sql change
</tr>
<tr>
<td>$row[8]</td>
</tr>
<tr><td><img alt='' src='divider.png' style='height:25px;
width:207px'/>
</td>
</tr>
<tr>
<td>
$row[5]</td>
</tr>
<tr>
<td>Details</td>
</tr>";
} // end loop