I have set up a MYSQL database and added a table with some data. I want to display this in a table in PHP that is 3 wide, like this:
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>item1</td>
<td>item2</td>
<td>item3</td>
</tr>
<tr>
<td>item4</td>
<td>item5</td>
<td>item6</td>
</tr>
<tr>
<td>item7</td>
<td>item8</td>
<td>item9</td>
</tr>
</table>
and so on...
Now, I have been using this PHP:
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>item1</td>
<td>item2</td>
<td>item3</td>
</tr>
<tr>
<td>item4</td>
<td>item5</td>
<td>item6</td>
</tr>
<tr>
<td>item7</td>
<td>item8</td>
<td>item9</td>
</tr>
</table>
and so on...
Now, I have been using this PHP:
CODE
<?php
//connect to the server
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
//connect to the database
mysql_select_db(product_index);
//query the database
$query = mysql_query("SELECT * FROM products WHERE type = 'bracelets'");
//fetch the results / convert results into an array
WHILE($rows = mysql_fetch_array($query)):
$product_name = $rows['product_name'];
$id = $rows['id'];
$description = $rows['description'];
$price = $rows['price'];
$image_large = $rows['image_large'];
$image_thumb = $rows['image_thumb'];
$page_link = $rows['page_link'];
$purchase_link = $rows['purchase_link'];
echo "$product_name<br>$description<br>$price<br>$image_large<br>$image_thumb<br>$page_link<br>$purchase_link<br><br><br>";
endwhile;
?>
//connect to the server
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
//connect to the database
mysql_select_db(product_index);
//query the database
$query = mysql_query("SELECT * FROM products WHERE type = 'bracelets'");
//fetch the results / convert results into an array
WHILE($rows = mysql_fetch_array($query)):
$product_name = $rows['product_name'];
$id = $rows['id'];
$description = $rows['description'];
$price = $rows['price'];
$image_large = $rows['image_large'];
$image_thumb = $rows['image_thumb'];
$page_link = $rows['page_link'];
$purchase_link = $rows['purchase_link'];
echo "$product_name<br>$description<br>$price<br>$image_large<br>$image_thumb<br>$page_link<br>$purchase_link<br><br><br>";
endwhile;
?>
No comments:
Post a Comment