Page 1 of 1

how i can show record colum wiz

Posted: Sun Mar 11, 2007 10:08 am
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.....

Posted: Sun Mar 11, 2007 11:27 am
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.

code plz

Posted: Sun Mar 11, 2007 11:37 am
by khubaib.php
plz can u explain it with the code i will be very thanks full to u ....

Posted: Sun Mar 11, 2007 11:45 am
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>";

Posted: Sun Mar 11, 2007 11:45 am
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.

thnks alot for helping

Posted: Sun Mar 11, 2007 12:06 pm
by khubaib.php
thanks a lot for helping me

how can i show more then one record

Posted: Mon Mar 12, 2007 5:54 am
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...