how i can show record colum wiz

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
khubaib.php
Forum Newbie
Posts: 6
Joined: Sun Mar 11, 2007 9:50 am

how i can show record colum wiz

Post by khubaib.php »

hi all.....

i have a problem...that i want to display my db records in columns like the flowing link

http://www.amazon.com/ref=topnav_gw_hg/ ... 86-1292050

u will find that there 3 record in each row so when the 4th record start it display in the other row...

plz some one help....

thanks in advance.....
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Use a table and keep a counter in the main loop that keeps track of which column you're on. Terminate/begin rows for every third column.
khubaib.php
Forum Newbie
Posts: 6
Joined: Sun Mar 11, 2007 9:50 am

code plz

Post by khubaib.php »

plz can u explain it with the code i will be very thanks full to u ....
mentor
Forum Contributor
Posts: 100
Joined: Sun Mar 11, 2007 11:10 am
Location: Pakistan

Post by mentor »

the code will be something like

Code: Select all

$_query = "select myItem from myThing where blah=blah";

$_results =mysql_query($_query);

$_i = 0;
echo "<TABLE><TR>";
while ($_row = mysql_fetch_assoc($_results)) {
    if ($_i > 0 && $_i % 3 == 0) {
        echo "</TR><TR>";
    }
    echo "<TD>" . $_row["myItem"] . "</TD>";
    $_i++;
}
echo "</TR></TABLE>";
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Look at mysql_fetch_array() and http://www.php.net/manual/en/language.o ... rement.php. If you don't know how to construct HTML tables, pay a visit to your favorite search engine.
khubaib.php
Forum Newbie
Posts: 6
Joined: Sun Mar 11, 2007 9:50 am

thnks alot for helping

Post by khubaib.php »

thanks a lot for helping me
khubaib.php
Forum Newbie
Posts: 6
Joined: Sun Mar 11, 2007 9:50 am

how can i show more then one record

Post by khubaib.php »

hey....

the code u just give me is showing one record in each column.....how i can display for example book image and book price and book author in one col om just like this link

http://www.amazon.com/b/ref=amb_link_42 ... ode=172635

u will see in this web page there is an image for the product and then the name of product and then there is it price i want to do just like that....

thanks in advance...
Post Reply