| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| NamePros Member | Displaying a Catalog Hey guys, I'm a designer turned coder and it would seem PHP has finally warmed up to me. One thing I can't figure out is how to display a catalog with multiple columns. Obviously I would need a <tr></tr> every four <td>'s and I can't quite get it working. This is the basic method I've been using thus far. Code: <?
$db = mysql_connect("localhost", "un", "pw");
mysql_select_db("db",$db);
$result = mysql_query("SELECT * FROM catagories ORDER BY od asc",$db);
while($myrow = mysql_fetch_array($result))
{
echo "CODE";
}
?>
$var = 0 before the while() portion and then $var = $var + 1 at the end, and then throw in the <tr></tr> when $var = multiple of 4 or something to that effect, but again I can't get it to work properly. Thanks for your time. |
| |
| | #2 (permalink) |
| NPQ's PA, Slave, and On Call Coder Technical Services | PHP Code:
__________________ |
| |
| | #4 (permalink) | |
| NPQ's PA, Slave, and On Call Coder Technical Services | Quote:
PHP Code:
__________________ | |
| |
| | #5 (permalink) |
| NamePros Regular | HTML Code: <?
$db = mysql_connect("localhost", "un", "pw");
mysql_select_db("db", $db);
$result = mysql_query("SELECT * FROM catagories ORDER BY od asc limit 8",$db);
echo '<table>';
while($myrow = mysql_fetch_array($result))
{
//THe below is what I typically do..
$variable = $myrow["column"];
$variable2 = $myrow["column2"];
$variable3 = $myrow["column3"];
$variable4 = $myrow["column4"];
echo "<tr><td>$variable</td><td>$variable2</td><td>$variable3</td><td>$variable4</td></tr>";
} //Something like that. Lol :p
echo '
</table>';
?> Hope it helps |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Catalog Website | Chanesaw | Website Development | 0 | 08-06-2005 08:14 AM |
| Displaying Content When A Checkbox Is Checked?? | TWM | Programming | 6 | 07-01-2005 07:58 AM |
| .cgi displaying as raw html in firefox | soloBRIAN | Programming | 0 | 05-18-2005 07:19 PM |
| Keeps displaying eye-related ads :| | Ringr | Google Adsense | 4 | 04-19-2005 02:47 PM |
| displaying colums | adam_uk | Programming | 4 | 07-16-2003 06:43 AM |