Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Results In A Row

Status
Not open for further replies.

EvilAsh

Technical User
Oct 22, 2005
56
GB
Hi there.

I have built a gallery page for a website using php/mysql.

Currently the data is returned in rows, one record per row.

What I would like to do is return the data two (or more) records per row.

This might be a silly question but how???

The code for the display so far is shown below:

Code:
//show results

while($i = mysql_fetch_row($result)) { 

echo"
<tr>";

//Product Thumbnail Image Link
echo "
<td ><font color='#000000' size='2' face='Arial, Helvetica, sans-serif'><A HREF=\"javascript:popUp('product.php?id=$i[0]')\"><img src=
$i[3] alt='Click for larger image.'></A></font></td>";

//Product ID
echo "
<td ><font color='#000000' size='2' face='Arial, Helvetica, sans-serif'>
Product ID: $i[0]</font></td>\n";

//Product Name
echo "
<td ><font color='#000000' size='2' face='Arial, Helvetica, sans-serif'><strong>
$i[1]</strong></font></td>\n";

//Product Price
echo "
<td ><font color='#000000' size='2' face='Arial, Helvetica, sans-serif'>
£$i[2]</font></td>\n";

Thanks :)
 
Ok, so right now you have four cells per row. What do you expect to have if you show two records? Eight cells? Or are you looking into restructuring. If it is just eight records, you should add another variable, say $first_item and check it on every new record. If it is true, then output new row (<tr>), if not, skip that and continue outputting cells (<td>). When you want to output a new row, set that variable to false. Or else, you can do it by number. Check if it is certain number, output row, if not output cell and increase the value of the number.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top