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>";
}
?>
could use a little help (html tables from mysql data)
Moderator: General Moderators
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))
{
if($cell == "1") {
echo "<tr>";
}
print "<td>
<div align="center">
<a href="\$moviename"><img src ="$moviename".".jpg">
<br>Filesize $filesize KB
<br>download button
<\div></td>";
if($cell == "3") {
echo "</tr>";
$cell = 0;
}
$cell++;
}
?>