CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   MySQL (http://www.codingforums.com/forumdisplay.php?f=7)
-   -   Need Help with database Queries in HTML tables (http://www.codingforums.com/showthread.php?t=274016)

jawittdesigns 09-24-2012 02:10 PM

Need Help with database Queries in HTML tables
 
Hi,

I having problems displaying queries from a mySQL database. I want to display images and descriptions in a html table four columns wide.

so far I cam up with this.

PHP Code:

while ($row mysql_fetch_array$result )){
$entry_name $row['entry_name'];
$entry_submition $row['entry_filename'];
$entry_pic '<div class="display-img"> <img src="../photos/'.$row['entry_filename'].'"></div>';
$count=4;
echo 
"<table>";
  
   echo 
'<tr>';
   for (
$counter=0$counter <$count$counter++){
        echo 
'<td>'.$entry_name.'<br>'.$entry_pic.'<td>';
   } 
  echo 
'</tr>';
echo 
"</table>";


This displays the table correctly, but it shows each item four times in each row.

What I need it to show each item once.

If any one can help. That would be great

Old Pedant 09-24-2012 09:11 PM

PHP Code:

$count 0;
echo 
"<table>\n";
while (
$row mysql_fetch_array$result ))
{
    if ( 
$count == ) { echo "<tr>\n"; }
    
$entry_name $row['entry_name'];
    
$entry_submition $row['entry_filename'];
    
$entry_pic '<div class="display-img"> <img src="../photos/'.$row['entry_filename'].'"></div>';

    echo 
'<td>'.$entry_name.'<br>'.$entry_pic.'<td>\n';

    ++
$count;
    if ( 
$count == 
    {
        echo 
"</tr>\n";
        
$count 0;
    }
}
echo 
"</table>\n"

Untested. I don't use PHP. But I use this technique with other languages and it works.


All times are GMT +1. The time now is 07:55 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.