Please can someone help, I'm new to PHP and I need to know how to display the data from mysql database using PHP in a format like so
ProductA(image) - ProductB(image) - ProductC(image)
ProdAName - ProdBName - ProdCName
ProdAPrice - ProdBPrice - ProdCPrice
I've managed to get the Product images displaying ok using this code
<?php
// Connect to Database
$con = mysql_connect("localhost","user","passwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// Select the Database
mysql_select_db("dbname", $con);
// Select the data from table_name
$result = mysql_query("SELECT product_name, network_deep_link, network_image_url, search_price FROM wp_products ORDER BY search_price");
// Display the table
echo "<table width='400' border='0' cellspacing='0' cellpadding='1'>";
// Put results into table
$counter = 0;
while ( $row = mysql_fetch_assoc( $result ) )
{
echo "<a href=\"" .$row['network_deep_link'] . "\">
<img src=\"" . $row['network_image_url'] . "\" border=0 alt=\"" . $row["network_image_url"] . "\" title=\"" . $row["product_name"] . "\">
</a>";
$counter++; # increment count every iteration
if ( $counter % 3 == 0 )
{
echo "<br>";
}
}
// Disconnect from Database
mysql_close($con);
?>
But what I also need to do is add ProdAName and ProdAPrice on the next lines like so I'm now using tables but have hit a problem when trying to put the results in <br>. If I put text inbetween the <br>text<br> it works, but not if I put .$row[product_name]
// Put results into table
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td><a href=\"" .$row['network_deep_link'] . "\">
<img src=\"" . $row['network_image_url'] . "\" border=0 alt=\"" . $row["network_image_url"] . "\" title=\"" . $row["product_name"] . "\"></a>";
echo "<br>.$row['product_name']<br>";
echo "<br>.$row['search_price']<br>";
echo "</td>";
}
echo "</table>";
Then I need to loop it like the first code example using the counter
Any help appreciated
Thanks
Gary