0

Hello,
Going to try to explain this as best I can. I have a bunch of stuff in a database and I need to display this info within a table. This isn't a problem at all but, I need it to only display 3 td tags per line and then move on to the row.

so i need it to do :

code:

<table>
<tr>
<td>My First Row</td>
<td>My First Row 2</td>
<td>My First Row 3</td>
</tr>

<tr>
<td>My Second Row</td>
<td>My Second Row 2</td>
<td>My Second Row 3</td>
</tr>
</table>

and continue to do this through every entry in the database table.

so I have something like this that will display the info:

code:

for ($i = 1; $i <= $num; $i++){
	
		$chairArray = mysql_fetch_array($chairResult);
		$chairName = $chairArray['name'];
		$chairDescription = $chairArray['description'];
		$chairImage = $chairArray['image'];
		
		echo "<tr>";
		echo "<td>";
		echo "<img src=\"images/catalog/ottomans/thumbs/$chairImage\" width=\"157\" height=\"147\" />";
		echo "<br />";
		echo $chairName;
		echo "</td>";
		echo "</tr>";
		
		
	}
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by SimonMayer
0

for ($i = 1; $i <= $num; $i++){

$chairArray = mysql_fetch_array($chairResult);
$chairName = $chairArray;
$chairDescription = $chairArray;
$chairImage = $chairArray;

echo "<tr>";
echo "<td>";
echo "<img src=\"images/catalog/ottomans/thumbs/$chairImage\" width=\"157\" height=\"147\" />";
echo "<br />";
echo $chairName;
echo "</td>";
echo "</tr>";


}

I think you would need to do something like this:

while($chairArray = mysql_fetch_array($chairResult))
{
	$chairName = $chairArray['name'];
	$chairDescription = $chairArray['description'];
	$chairImage = $chairArray['image'];
	echo "
	<tr>
		<td>
			<img src='mages/catalog/ottomans/thumbs/".$chairImage."' width='157' height='147' />
		</td>
		<td>
			".$chairName."
		</td>
		<td>
			".$chairDescription."
		</td>
	</tr>";
}

Note - I have replaced the escaped double quotes on your <img /> tag with single quotes, as I find it easier to see what is happening.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.