Sepharoth Posted February 29, 2008 Share Posted February 29, 2008 Hi I really need some help with a small problem with my php and mysql coding... can u please take a look at this site: http://duntuk.co.uk/ali/ and login with the username: abdaal.ali@gmail.com, and the password 116111 if u then go to http://duntuk.co.uk/ali/comptest.php, u will see some tables arranged in groups of 2, but the stuff in each pair is exactly the same... I would like to get a result of something like : http://duntuk.co.uk/products.php, with the tables in 2 columns. At the moment i am using the while ($row...) with a div containing the 2 tables, side by side. The loop is working fine, but i need to know how i can change the values in the second table to match a new record, if this makes sense This is the code i am currently using: <?php require "include.php"; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php $i = 0; while ($row = mysql_fetch_array($compactive)) { $cid = $row[id]; $ctype = $row[type]; $reqentno = $row[maxentries]; $prizequery = "select * from prizes where compid='$cid' limit 0,1" ; $prizename = $connect->ex("$prizequery","name"); $prizeimg = $connect->ex("$prizequery","img"); $prizedesc = $connect->ex("$prizequery","dscrip"); $entriesquery = mysql_query("select * from entries where compid='$cid'"); $cent = mysql_num_rows($entriesquery); ?> <div class="asd" id="asd"> <div> <table width="475" height="164" border="0" align="left" cellpadding="0" cellspacing="0" background="images/compbox.jpg" style="margin-left:12px;"> <tr> <td width="13" rowspan="5"> </td> <td width="100" rowspan="5"><img src="images/1bl.gif" alt="asd" width="100" height="100" /></td> <td width="17" rowspan="5"> </td> <td width="97" height="19"> </td> <td width="248"> </td> </tr> <tr> <td><strong>Prize:</strong></td> <td width="248"><?php echo $prizename; ?> </td> </tr> <tr> <td> </td> <td width="248"><?php echo $prizedesc; ?> </td> </tr> <tr> <td><strong>Details:</strong></td> <td width="248"><?php if ($ctype == "inwin") { $type = "Instant Win"; } if ($ctype == "endate") { $type = "Ends on $endate"; } if ($ctype == "reqent") { $cmin = $reqentno - $cent; $type = "$cmin Entries Remaining"; } echo $type; ?></td> </tr> <tr> <td height="19"><strong>Start Date:</strong></td> <td width="248"><?php echo $row[date]; ?></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td><strong>Comp ID:</strong></td> <td><?php if ($ctype == "inwin") { $cx = "IW"; } if ($ctype == "endate") { $cx = "EN"; } if ($ctype == "reqent") { $cx = "RE"; } $cx = "$cx$cid"; echo $cx; ?></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </table> <div> <table width="475" height="164" border="0" cellpadding="0" cellspacing="0" background="images/compbox.jpg" style="margin-right:12px;"> <tr> <td width="13" rowspan="5"> </td> <td width="100" rowspan="5"><img src="images/1bl.gif" alt="asd" width="100" height="100" /></td> <td width="17" rowspan="5"> </td> <td width="97" height="19"> </td> <td width="248"> </td> </tr> <tr> <td><strong>Prize:</strong></td> <td width="248"><?php echo $prizename; ?> </td> </tr> <tr> <td> </td> <td width="248"><?php echo $prizedesc; ?> </td> </tr> <tr> <td><strong>Details:</strong></td> <td width="248"><?php if ($ctype == "inwin") { $type = "Instant Win"; } if ($ctype == "endate") { $type = "Ends on $endate"; } if ($ctype == "reqent") { $cmin = $reqentno - $cent; $type = "$cmin Entries Remaining"; } echo $type; ?></td> </tr> <tr> <td height="19"><strong>Start Date:</strong></td> <td width="248"><?php echo $row[date]; ?></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td><strong>Comp ID:</strong></td> <td><?php if ($ctype == "inwin") { $cx = "IW"; } if ($ctype == "endate") { $cx = "EN"; } if ($ctype == "reqent") { $cx = "RE"; } $cx = "$cx$cid"; echo $cx; ?></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </table> </div> </div> </div> <?php } ?> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> </body> </html> So, the thing i need help with is: Using PHP and MySQL, how do I get all the tables to show different records from the database, and not have 2 showing the same thing? I have tried using one of the mysql multi-column tutorials in this forum, but for some reason it didnt work... Can someone please help me or point me in the right direction for this? Thanks ever so much -Sepharoth Quote Link to comment Share on other sites More sharing options...
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.