Snaip3Rs Posted May 21, 2010 Report Posted May 21, 2010 man ir problēma ar table pielikšana visiem iznākumiem! Te būs kods! </head> <body> <table border=1> <tr> <th>Albums</th> <th>Izpilditajs</th> <th>Dziesma</th> <th>Balsis</th> <th>Nobalsot</th> </tr> <?php /** Display the results from the database **/ $q = "SELECT * FROM top"; $r = mysql_query($q); if(mysql_num_rows($r)>0): //table is non-empty while($row = mysql_fetch_assoc($r)): $net_vote = $row['votes_up'] - $row['votes_down']; //this is the net result of voting up and voting down ?> <tr> <th><?php echo $row['albums']; ?></th> <th><?php echo $row['izpilditajs']; ?></th> <th><?php echo $row['dziesma']; ?></th> <th><span class='votes_count' id='votes_count<?php echo $row['id']; ?>'><?php echo $net_vote.""; ?></span></th> <th> <span class='vote_buttons' id='vote_buttons<?php echo $row['id']; ?>'> <a href='javascript:;' class='vote_up' id='<?php echo $row['id']; ?>'></a> <a href='javascript:;' class='vote_down' id='<?php echo $row['id']; ?>'></a> </span> </th> </tr> </table> <?php endwhile; endif; ?> </body> </html> Un ir tāda problēma ka tikai pirmo rindu no datubāzesieliek tabulā a parējās rindas paliek bez tabulas stāv vienā rindā plikas! :D Quote
marcis Posted May 21, 2010 Report Posted May 21, 2010 Jo pēc pirmā cikla posma tu aizver tabulu... Quote
zintis8789 Posted May 21, 2010 Report Posted May 21, 2010 </head> <body> <table border=1> <tr> <th>Albums</th> <th>Izpilditajs</th> <th>Dziesma</th> <th>Balsis</th> <th>Nobalsot</th> </tr> <?php /** Display the results from the database **/ $q = "SELECT * FROM top"; $r = mysql_query($q); if(mysql_num_rows($r)>0): //table is non-empty while($row = mysql_fetch_assoc($r)): $net_vote = $row['votes_up'] - $row['votes_down']; //this is the net result of voting up and voting down ?> <tr> <th><?php echo $row['albums']; ?></th> <th><?php echo $row['izpilditajs']; ?></th> <th><?php echo $row['dziesma']; ?></th> <th><span class='votes_count' id='votes_count<?php echo $row['id']; ?>'><?php echo $net_vote.""; ?></span></th> <th> <span class='vote_buttons' id='vote_buttons<?php echo $row['id']; ?>'> <a href='javascript:;' class='vote_up' id='<?php echo $row['id']; ?>'></a> <a href='javascript:;' class='vote_down' id='<?php echo $row['id']; ?>'></a> </span> </th> </tr> <?php endwhile; endif; ?> </table> </body> </html> 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.