Page 1 of 1

[SOLVED] Rows instead of tables

Posted: Tue Jul 06, 2004 7:44 am
by ddragas
I'm making individual tables. What am I doing wrong?

I want to make one table, and make rows in that table


Here is complete code

Code: Select all

<?php 

include("con_db.php"); 

$query_count2 = mysql_query("select city, mjesto, count(*) as 'broj_iznajmljivaca' 
from apartmani 
where Zupanija = '$zupanija_smjestaja' and vrsta_smjestaja='$vrsta'  and kategorija='$kategorija' 
group by city, mjesto 
order by city ") or 
die (mysql_error()); 


//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
         $color = '#CCCC99'; 
         while ($result_row2 = mysql_fetch_assoc($query_count2)){ 
         $totalrows2 = $result_row2['broj_iznajmljivaca']; 
         $grad = $result_row2["city"]; 
         $mjesto =  $result_row2["mjesto"]; 
          
         $color = ($color === '#CCCC99' ? '#CCCCCC' : '#CCCC99'); 
         echo "<table border = -1 table width="100%">"; 
         if($vrsta=="apartman"){ 
         echo "<td width="40%"align="left" bgcolor= "  . $color  . ">" . $font .  $grad  . " (" . $mjesto. ")" . "</td><td width="20%"align="center" bgcolor= "  . $color  . ">" . $font . '<a href="result_app.php?grad='.urlencode($grad).'&mjesto=' . urlencode($mjesto) .'&vrsta=' . urlencode($vrsta) .'">' .  $totalrows2 .  '</a>' . "</td></tr>";} 
         echo "</table>"; 
   //      $color = ($color === '#CCCC99' ? '#CCCCCC' : '#CCCC99'); 
         } 
mysql_free_result($query_count2); 
mysql_close($conn); 

?> 
<?php

?>

Posted: Tue Jul 06, 2004 7:53 am
by launchcode
Take the "echo <table>" (blah blah) line outside of your WHILE loop then! :) Put it before and put the closing table tag at the } ending the while loop.

Posted: Tue Jul 06, 2004 11:09 am
by ddragas
Thanx