Page 1 of 1

could use a little help (html tables from mysql data)

Posted: Sun Aug 11, 2002 6:30 am
by Shamu
Hello,

I am trying to make a gallery for movies in php to display data from my mysql database in a table with 3 colums and a row for each 3 more movies in the database until it finishes. I am very new to php and could use some help. It barely works now and when it does it displays the same data in all 3 colums.. how do I get it to display the different data in each cell? any help is much appreciated!

<body bgcolor="#FFFFFF" text="#6666FF">
<?
$dbase = mysql_connect("localhost","user","password") or die ("Cant connect to sql");
mysql_select_db("family",$dbase) or die ("Cant connect to database");

$results = mysql_query("SELECT * FROM movies ORDER BY moviename DESC");

print "<center><table>";

while(list($catagory, $moviename, $filesize, $time)=mysql_fetch_row
($results))
{
print "<tr><td>

<div align=\"center\">
<a href="\$moviename\"><img src =\"$moviename".".jpg\">
<br>Filesize $filesize KB
<br>download button
<\div></td>
<td>
<a href="\$moviename\"><img src =\"$moviename".".jpg\">
<br>Filesize $filesize KB
<br>download button
<\div>
</td>
<td>
<a href="\$moviename\"><img src =\"$moviename".".jpg
<br>Filesize $filesize KB
<br>download button
<\div>
</td>
</tr>";
}

?>

Posted: Sun Aug 11, 2002 12:12 pm
by MattF
Try this:

Code: Select all

<body bgcolor="#FFFFFF" text="#6666FF">
<?
$dbase = mysql_connect("localhost","user","password") or die ("Cant connect to sql");
mysql_select_db("family",$dbase) or die ("Cant connect to database");

$results = mysql_query("SELECT * FROM movies ORDER BY moviename DESC");

print "<center><table>";
$cell = "1";
while(list($catagory, $moviename, $filesize, $time)=mysql_fetch_row
($results))
&#123;
if($cell == "1") &#123;
    echo "<tr>";
&#125;
print "<td>
<div align="center">
<a href="\$moviename"><img src ="$moviename".".jpg">
<br>Filesize $filesize KB
<br>download button
<\div></td>";
if($cell == "3") &#123;
echo "</tr>";
$cell = 0;
&#125;
$cell++;
&#125;

?>