NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Displaying a Catalog

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 09-16-2005, 03:11 AM THREAD STARTER               #1 (permalink)
NamePros Member
Join Date: Dec 2004
Posts: 30
n0dice is an unknown quantity at this point
 



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";
 
} 
	
?>
My initial thoughts were that I would need to add something like:

$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.
????: NamePros.com http://www.namepros.com/programming/124139-displaying-a-catalog.html

Thanks for your time.
n0dice is offline  
Old 09-16-2005, 03:21 AM   #2 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
PHP 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)) 

//THe below is what I typically do..
$variable $myrow["column"];
????: NamePros.com http://www.namepros.com/showthread.php?t=124139
$variable2 $myrow["column2"];

echo 
$variable "<br>";
echo 
$variable2 "<br>";

    
?>
Eric is offline  
Old 09-16-2005, 03:34 AM   #3 (permalink)
NamePros Regular
 
dkin69's Avatar
Join Date: May 2005
Posts: 358
dkin69 has a spectacular aura aboutdkin69 has a spectacular aura about
 



if I understand correctly he wants it laid out in table form

example

row 1 | row 2 | row 3 | row 4 |
row 5 | row 6 | row 7 | row 8 |

etc
dkin69 is offline  
Old 09-16-2005, 04:09 AM   #4 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Originally Posted by dkin69
if I understand correctly he wants it laid out in table form

example

row 1 | row 2 | row 3 | row 4 |
row 5 | row 6 | row 7 | row 8 |

etc
PHP Code:
<?
????: NamePros.com http://www.namepros.com/showthread.php?t=124139
$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))
{
//THe below is what I typically do..
$variable $myrow["column"];
$variable2 $myrow["column2"];

echo 
"<table>
<tr>
<td>
$variable</td>
<td>
$variable2</td>
</tr>
</table>"
;
//Something like that. Lol :p
    
?>
Eric is offline  
Old 09-16-2005, 04:26 AM   #5 (permalink)
NamePros Regular
 
dkin69's Avatar
Join Date: May 2005
Posts: 358
dkin69 has a spectacular aura aboutdkin69 has a spectacular aura about
 



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>';    
?>
There, that should give you two rows, to get more change limit 8 to 16 32 whatever.
????: NamePros.com http://www.namepros.com/showthread.php?t=124139

Hope it helps
dkin69 is offline  
Old 09-16-2005, 06:41 AM   #6 (permalink)
NamePros Regular
 
moondog's Avatar
Join Date: Jun 2004
Posts: 587
moondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to all
 



.
__________________
Can't wait to be out of this forsaken business. Getting close! :)
moondog is offline  
Old 09-16-2005, 12:28 PM   #7 (permalink)
NamePros Regular
 
dkin69's Avatar
Join Date: May 2005
Posts: 358
dkin69 has a spectacular aura aboutdkin69 has a spectacular aura about
 



Originally Posted by moondog
.
how helpful! lol.
dkin69 is offline  
Closed Thread


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 09:14 AM
Displaying Content When A Checkbox Is Checked?? TWM Programming 6 07-01-2005 08:58 AM
.cgi displaying as raw html in firefox soloBRIAN Programming 0 05-18-2005 08:19 PM
Keeps displaying eye-related ads :| Ringr Google Adsense 4 04-19-2005 03:47 PM
displaying colums adam_uk Programming 4 07-16-2003 07:43 AM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 04:18 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger