killingbegin Posted February 6, 2009 Report Posted February 6, 2009 (edited) Hi im trying to make a small kind of "eshop" not for a speciall reason.Anyways i got a table that contains username - password-Gender im inserting there the following :--- - firstname-lastname-gender. i want my results preview be 4 adds in a row no all together for example for the data(im using the same names now just for faster): 1)nick rayton,Male 2)nick rayton,Male 3)nick rayton,Male 4)nick rayton,Male 5)nick rayton,Male not to preview like this but like : 1)nick rayton 2)nick rayton, 3)nick rayton 4)nick rayton Male Male Male Male 5)nick rayton 6)nick rayton, 7)nick rayton 8)nick rayton Male Male Male Male im using this code to extract a row <?php $count = 0; while($row = mysql_fetch_array($strquery)) { $count++; extract($row); if($count < 5) { echo "$username $password $Gender\n"; } else if ($count == 4) { echo ""; $count = 1; } } so what im understanding doing that is print username password gender 4 times in one row and when the count be 4 what i want "to have only 4 at the first row go at second row or third row) if somone can help with that. .That code can only result all things in td td td td for a reason. SORRY FOR MY BAD LANG thank you Edited February 6, 2009 by killingbegin Quote
sjhwebdesign Posted February 6, 2009 Report Posted February 6, 2009 <?php $columns = 4; $col = 0; while($row = mysql_fetch_array($strquery)) { if ($col == $columns) { $col = 0; } if ($col == 0) { ?> <?php } ?> $username $password $Gender <?php $col = $col+1; if ($col == $columns) { ?> <?php } } ?> Quote
killingbegin Posted February 7, 2009 Author Report Posted February 7, 2009 Thanx a lot for the solution just a tip $username $password $Gendershow for all my rows in db the data $username $password $Gender this need only <?php echo $username $password $Gender?> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.