SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Jun 2007
    Location
    Plymouth uk
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question need some help with display in tables

    ok have this code which displays text and image but dosnt line up very well and was told tables would work better
    so need some help to set up
    here is the code i am using at moment and jpeg of results
    PHP Code:
     $data mysql_query("SELECT * FROM gallery ") or die(mysql_error());
     
    //Puts it into an array 
    while($info mysql_fetch_array$data )) 

    //Outputs the image and other data
    Echo " ".$info['pet'] . " <br>";
    Echo 
    "<img src=http://www.djbcaravanhire.co.uk/pics/".$info['pic'] ." alt=\"Image\" align=\"left\" width=\"200px\" height=\"150px\" hspace=\"10px\" vspace=\"8px\"> <br>";


    cheers Doug
    Attached Images Attached Images
    an old man of 60 trying to keep up with the youngsters he he
    http://lostpetsplymouth.net16.net

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should first manually create the html you desire. Then, after you have done that, worry about creating the html dynamically with php.

  3. #3
    SitePoint Addict
    Join Date
    Jun 2007
    Location
    Plymouth uk
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for reply where can i go and see how to do what you suggest
    Doug
    an old man of 60 trying to keep up with the youngsters he he
    http://lostpetsplymouth.net16.net

  4. #4
    SitePoint Enthusiast nrg_alpha's Avatar
    Join Date
    Dec 2008
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dougvcd View Post
    PHP Code:
     $data mysql_query("SELECT * FROM gallery ") or die(mysql_error());
     
    //Puts it into an array 
    while($info mysql_fetch_array$data )) 

    //Outputs the image and other data
    Echo " ".$info['pet'] . " <br>";
    Echo 
    "<img src=http://www.djbcaravanhire.co.uk/pics/".$info['pic'] ." alt=\"Image\" align=\"left\" width=\"200px\" height=\"150px\" hspace=\"10px\" vspace=\"8px\"> <br>";


    Unrelated to the solution, note that you are echoing with double quotes. But if you are going to do it that way, variables can be inside those double quotes and with the use of { and }, will be interpreted by the PHP interpreter..

    So
    PHP Code:
    Echo " ".$info['pet'] . " <br>"
    Could become:
    PHP Code:
    echo ${info['pet']} <br>"
    Or you could keep the format you have and simply use single quotes instead:
    PHP Code:
    echo ' ' $info['pet'] . ' <br>'
    EDIT - Understand that content in double quotes requires the PHP interpreter to check for variables to be translated, while single quotes do not. As a result, the single quotes will output literally what it contains (no variables will be translated in those quotes).

  5. #5
    SitePoint Addict
    Join Date
    Oct 2008
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe what you were looking for was something like this with tables.
    PHP Code:
    $data mysql_query("SELECT * FROM gallery ") or die(mysql_error());

    //Puts it into an array 
    echo '<table>';
    while(
    $info mysql_fetch_array$data )) 

    //Outputs the image and other data
        
    echo '<tr><td>'$info['pet'] .'</td></tr>';
        echo 
    '<tr><td><img src=http://www.djbcaravanhire.co.uk/pics/' .$info['pic'] .' alt=\"Image\" align=\"left\" width=\"200px\" height=\"150px\" hspace=\"10px\" vspace=\"8px\"></td></tr>';
    }
    echo 
    '</table>'

  6. #6
    SitePoint Addict
    Join Date
    Jun 2007
    Location
    Plymouth uk
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for that
    just tried it and dont get any images displayed only the titles
    cheers
    Doug
    an old man of 60 trying to keep up with the youngsters he he
    http://lostpetsplymouth.net16.net


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •