Results 1 to 5 of 5

Thread: Image gallery

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    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

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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;

    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    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.

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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>
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    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
  •  



Click Here to Expand Forum to Full Width