Ok, basically i have DB full of products, and it has cells of information for 'name', 'thumbnail', 'price', etc etc.
I know how to get all the products to display on the page in a single row:
mysql_select_db($sqldb);
$sql = "SELECT * FROM products WHERE category = '$type'";
$result=mysql_query($sql);
if (!$result) {
print mysql_error()." ERROR - browse query failed.";
}
while($row = mysql_fetch_array($result)) {
$product_id = $row[id];
echo '<img src="http://www.mysite.com/thumbnails/'.$row["thumb"].'"><br></td></tr>';
echo '<tr><td><a href="http://www.mysite.com/folder/'.$product_id.'.html">'.$row[name].'<br></a>';
echo ''.$row[price].'<br><br>';
echo ''.$row[description].'<br><br>';
$line_count++;
}
So that works fine to list them all in a single row, but i want to list them all in 2 rows, sorted by 'name', i've used this code successfully befor but only with a single field being queried, i can't get it to work right querying all the above info:
<?
include('connect.php');
mysql_select_db('und_mov') or exit(mysql_error());
$query = 'SELECT title FROM list ORDER BY title';
$result = mysql_query($query) or exit(mysql_error());
while ($row = mysql_fetch_assoc($result)) {$array[] = $row['title'];}
$chunks = array_chunk($array, ceil(count($array) / 2));
echo '
Total Movies: <b>' . mysql_num_rows($result) . '</b><br><br>
<table border="0" cellpadding="5">
<tr valign="top">
';
foreach ($chunks as $value)
{
echo '<td><table border="0" cellpadding="5">';
foreach ($value as $title)
{
if (!$title) {$title = ' ';}
echo '<tr><td><a href="http://www.imdb.com/find?q=' . $title . ';tt=on;nm=on;mx=20">' . $title . '</td></tr>';
}
echo '</table></td>';
}
echo '</tr></table>';
?>
So i'm hoping someone is kind enough to show me (or tell) what i need to do to get all the fields from a query into the array so i can use them in the loop...
and even better, if they could ALSO show how to do this with 3 colums 🙂