Jump to content
php.lv forumi

Problema ar table


Snaip3Rs

Recommended Posts

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

Link to comment
Share on other sites

</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>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...