|
-
Mar 6th, 2005, 02:27 PM
#1
Thread Starter
PowerPoster
Image gallery
Ok i am trying to set up a script to show images in the format
1234
5678
etc etc
the paths are all stored in a DB, i think this is more of a html style question rather than PHP? not sure...
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#000000">
<table width="79%" height="505" border="1" align="center" cellpadding="4" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#000000">
<tr>
<td height="501" valign="top"><table width="99%" height="179" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
<tr>
<?php
$title = $_GET['title'];
$host="localhost";
$user="";
$password="";
$database="";
$connection = mysql_connect($host,$user,$password);
$db = mysql_select_db($database,$connection);
$query = "SELECT * FROM tblGallery WHERE title = '$title'";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result))
{
$i = $i + 1;
echo $row['path'];
echo "<tr width='25'><img src='" . $row['path'] . "' width='140' height='140'></tr>";
if ($i = 4)
{
echo "</tr><tr>";
$i = 0;
}
}
?>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
Any input would be appriciated, if you have any better ideas how to do this let me know 
Pino
-
Mar 6th, 2005, 02:35 PM
#2
Re: Image gallery
Slight improvement:
PHP Code:
$i = 1;
while ($row = mysql_fetch_array($result))
{
echo $row['path'];
echo "<tr width='25'><img src='" . $row['path'] . "' width='140'
height='140'></tr>";
if (($i % 4) == 0) /* its easier to use MOD here instead */
{
echo "</tr><tr>";
}
++$i;
}
-
Mar 6th, 2005, 02:40 PM
#3
Thread Starter
PowerPoster
Re: Image gallery
Thanks visualad,
I dont think it worked though i'm doing somthing wrong with the tags somewhere, see here...
*link removed *
Last edited by Pino; Mar 6th, 2005 at 02:48 PM.
-
Mar 6th, 2005, 02:55 PM
#4
Re: Image gallery
You are not using <td> tags. <tr> tags denote a new table row and all Table Data must be contained in <td> tags. Change your PHP script to get the HTML code looking like this and it should be fine:
HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#000000">
<table width="79%" height="505" border="1" align="center" cellpadding="4" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#000000">
<tr>
<td height="501" valign="top">
<table width="99%" height="179" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
<tr>
<td>test</td>
</tr>
<tr>
<td>
<img src='http://control.cerysmatthews.info/cgi-bin/configNEWdatabase.gif' width='140'
height='140'>
</td>
<td>
<img src='$titlehttp://control.cerysmatthews.info/cgi-bin/configNEWdatabase.gif' width='140'
height='140' />
</td>
<td>
<img src='$titlehttp://control.cerysmatthews.info/cgi-bin/configNEWdatabase.gif' width='140'
height='140'>
</td>
<td>
<img src='http://control.cerysmatthews.info/cgi-bin/configNEWdatabase.gif' width='140'
height='140'>
</td>
</tr>
<tr>
<td>
<img src='http://control.cerysmatthews.info/cgi-bin/configNEWdatabase.gif' width='140'
height='140'>
</td>
<td>
<img src='' width='140' height='140' />
</td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
-
Mar 6th, 2005, 02:58 PM
#5
Thread Starter
PowerPoster
Re: Image gallery
Thanks i'll look into it 
Thanks for the help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|