03-06-2008, 03:57 PM
|
#3 (permalink)
|
|
The Contributor
Join Date: Jan 2008
Posts: 87
Thanks: 49
|
Thanks again, Alan. I tried taking the code and modifying it a little, but I don't know much about arrays - I will read more in-depth soon.
The example:
PHP Code:
<?php
$values = range(1, 31); $rows = array_chunk($values, 7);
print "<table>\n"; foreach ($rows as $row) { print "<tr>\n"; foreach ($row as $value) { print "<td>" . $value . "</td>\n"; } print "</tr>\n"; } print "</table>\n";
?>
$rows as $row not sure what that means, $row is specified anywhere.
I tried:
PHP Code:
<?php //Create a query to display the ROCK artist in the category section
$rock_category = 'SELECT * FROM products WHERE cd_category = "rock"'; $rock_result = mysql_query($rock_category);
$num_rock = mysql_numrows($rock_result);
$category_artist_rock = mysql_result($rock_result, "cd_artist");
$rows = array_chunk_vertical($category_artist_rock, 7);
print "<table>\n"; foreach ($rows as $row) { print "<tr>\n"; foreach ($row as $category_artist_rock) { print "<td>" . $category_artist_rock . "</td>\n"; } print "</tr>\n"; } print "</table>\n";
?>
I know that's completely wrong and I need to add $num_rock in there somewhere. Just not sure where. I think I need to study this more.
Also tried:
PHP Code:
<?php $values = range(1, $num_rock); $rows = array_chunk_vertical($values, 7);
print "<table>\n"; foreach ($rows as $row) { print "<tr>\n";
foreach ($row as $value) { print "<td>" . $value . "</td>\n"; }
print "</tr>\n"; }
print "</table>\n"; ?>
But now I need to put the actual values I want to output in somewhere - $category_artist_rock
|
|
|
|