SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member Don Mullet's Avatar
    Join Date
    Feb 2007
    Location
    Oxford UK
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Images in a table trouble

    Hi,

    I have an issue with an image URL I'm trying to get working to show a certain image for a certain row from a MySQL database.

    I have 1 table in the database which contains all the text and information about the product, and 1 table in the databasae which contains the images stored in BLOB binary form. I can view both indiviually, but when I attempt to make the image appear using the URL of the PHP grab page, for some reason it will not display the image. The image is uniquely identified in both tables as pid.

    The code I am using is as follows, I've hand coded this myself and can't figure out why it won't work, any help will be very helpfull.

    PHP Code:
    <?php

    $db 
    mysql_connect("localhost""xxx""xxx");

    mysql_select_db("roberts_pianos",$db);

    $result mysql_query("SELECT * FROM stock WHERE SC='c' ORDER BY price DESC",$db);

    if (
    $myrow mysql_fetch_array($result)) {

      echo 
    "<table width=100% >\n";

      echo 
    "<tr><th align=left>RP:</th><th align=left>Piano:</th><th align=left>Type:</th><th align=left>Description:</th><th align=left>Serial Number:</th><th align=left>Year:</th><th align=left>Price:</th><th align=left>Dimensions:</th><th align=left>Location:</th><th align=left>Image:</th></tr>\n";

      do {

    $apostrophe="'";
    $pid $myrow -> pid;
    if(
    $myrow["guarantee"]=='No guarantee'){$guarantee='No g'.$apostrophe.'tee';}
    if(
    $myrow["guarantee"]=='1 year guarantee'){$guarantee='1yr g'.$apostrophe.'tee';}
    if(
    $myrow["guarantee"]=='2 year guarantee'){$guarantee='2yr g'.$apostrophe.'tee';}
    if(
    $myrow["guarantee"]=='3 year guarantee'){$guarantee='3yr g'.$apostrophe.'tee';}
    if(
    $myrow["guarantee"]=='5 year guarantee'){$guarantee='5yr g'.$apostrophe.'tee';}
    if(
    $myrow["guarantee"]=='10 year guarantee'){$guarantee='10yr g'.$apostrophe.'tee';}
    if(
    $myrow["design"]==''){$design='';}else{$design=substr($myrow["design"],0,1).'/'.substr($myrow["design"],1,1);}
    if(
    $myrow["ptype"]=='Upright'){$length_or_depth='D';}else{$length_or_depth='L';}
    if(
    $myrow["height"]==0){$height='H';}else{$height=$myrow["height"];}
    if(
    $myrow["width"]==0){$width='W';}else{$width=$myrow["width"];}
    if(
    $myrow["depth"]==0){$depth=$length_or_depth;}else{$depth=$myrow["depth"];}
    if(
    $myrow["RP"]<261116){$dimensions=$myrow["dimensions"];}else{$dimensions=$height.'x'.$width.'x'.$depth;}
    if((
    $dimensions=='HxWxD')||($dimensions=='HxWxL')){$showdimensions='';}else{$showdimensions=$dimensions;}
    if(
    $myrow["price"]<1){$showprice='';}else{$showprice=''.$myrow["price"];}
    if((
    $myrow["casework"]=='')&&(strlen(trim($myrow["description"])) >1)&&(strlen(trim($myrow["design"]))>0)){$indescription=$design.' '.$myrow["description"].'. '.$guarantee;}
    elseif((
    $myrow["description"]=='')&&(strlen(trim($myrow["casework"]))>0)&&(strlen(trim($myrow["design"]))>0)){$indescription=$design.' '.$myrow["casework"].'. '.$guarantee;}
    elseif((
    $myrow["casework"]=='')&&($myrow["description"]=='')&&(strlen(trim($myrow["design"]))>0)){$indescription=$design.' '.$guarantee;}
    elseif((
    $myrow["casework"]=='')&&($myrow["description"]=='')&&($myrow["design"]=='')){$indescription=$design.' '.$guarantee;}
    elseif((
    strlen(trim($myrow["description"])) >1)&&(strlen(trim($myrow["casework"])) >1)){$indescription=$design.' '.$myrow["description"].' in '.$myrow["casework"].'. '.$guarantee;}
    if(
    $myrow["RP"]<261116){$description=$myrow["description"];}else{$description=$indescription;}
    if(
    $myrow["RP"]<261116){$piano=$myrow["make"];}else{$piano=$myrow["make"].' '.$myrow["model"];}

    printf("<tr><td>%s</td><td>$piano</td><td>%s</td><td>$description</td><td>%s</td><td>%s</td><td>$showprice</td><td>$showdimensions</td><td>%s</td><td><img src=\"view2.php?pid=".$pid."></td></tr>\n"$myrow["RP"], $myrow["ptype"], $myrow["serial"], $myrow["year"], $myrow["location"]);

      } while (
    $myrow mysql_fetch_array($result));

        echo 
    "</table>\n";

    } else {

        echo 
    "Sorry, no records were found!";    

    }

    mysql_close();

    ?>
    Thanks

    Adam
    Don Mullet -
    www.donmullet.com

  2. #2
    SitePoint Member Don Mullet's Avatar
    Join Date
    Feb 2007
    Location
    Oxford UK
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't worry, managed to fix it now, I ended up setting it to a &#37;s and adding it to the bottom of the list.

    Ad
    Don Mullet -
    www.donmullet.com

  3. #3
    SitePoint Member Don Mullet's Avatar
    Join Date
    Feb 2007
    Location
    Oxford UK
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I seem to have broken this again but now it is using slightly different code ->

    PHP Code:
      <?php


    $db 
    mysql_connect("localhost""root""rootwdp");
    mysql_select_db("roberts_pianos",$db);
    $result mysql_query("SELECT * FROM stock WHERE SC='c' ORDER BY price DESC",$db);
    if (
    $myrow mysql_fetch_array($result)) {

      echo 
    "<table width=100% >\n";

      echo 
    "<tr><th align=left>RP:</th>
              <th align=left>Piano:</th>
            <th align=left>Type:</th>
            <th align=left>Description:</th>
            <th align=left>Serial Number:</th>
            <th align=left>Year:</th>
            <th align=left>Price:</th>
            <th align=left>Dimensions:</th>
            <th align=left>Location:</th>
            <th align=left>Image:</th>
            </tr>\n"
    ;

      do {

    $serial $myrow -> serial;
    $apostrophe="'";
    if(
    $myrow["guarantee"]=='No guarantee'){$guarantee='No g'.$apostrophe.'tee';}
    if(
    $myrow["guarantee"]=='1 year guarantee'){$guarantee='1yr g'.$apostrophe.'tee';}
    if(
    $myrow["guarantee"]=='2 year guarantee'){$guarantee='2yr g'.$apostrophe.'tee';}
    if(
    $myrow["guarantee"]=='3 year guarantee'){$guarantee='3yr g'.$apostrophe.'tee';}
    if(
    $myrow["guarantee"]=='5 year guarantee'){$guarantee='5yr g'.$apostrophe.'tee';}
    if(
    $myrow["guarantee"]=='10 year guarantee'){$guarantee='10yr g'.$apostrophe.'tee';}
    if(
    $myrow["design"]==''){$design='';}else{$design=substr($myrow["design"],0,1).'/'.substr($myrow["design"],1,1);}
    if(
    $myrow["ptype"]=='Upright'){$length_or_depth='D';}else{$length_or_depth='L';}
    if(
    $myrow["height"]==0){$height='H';}else{$height=$myrow["height"];}
    if(
    $myrow["width"]==0){$width='W';}else{$width=$myrow["width"];}
    if(
    $myrow["depth"]==0){$depth=$length_or_depth;}else{$depth=$myrow["depth"];}
    if(
    $myrow["RP"]<261116){$dimensions=$myrow["dimensions"];}else{$dimensions=$height.'x'.$width.'x'.$depth;}
    if((
    $dimensions=='HxWxD')||($dimensions=='HxWxL')){$showdimensions='';}else{$showdimensions=$dimensions;}
    if(
    $myrow["price"]<1){$showprice='';}else{$showprice='£'.$myrow["price"];}
    if((
    $myrow["casework"]=='')&&(strlen(trim($myrow["description"])) >1)&&(strlen(trim($myrow["design"]))>0)){$indescription=$design.' '.$myrow["description"].'. '.$guarantee;}
    elseif((
    $myrow["description"]=='')&&(strlen(trim($myrow["casework"]))>0)&&(strlen(trim($myrow["design"]))>0)){$indescription=$design.' '.$myrow["casework"].'. '.$guarantee;}
    elseif((
    $myrow["casework"]=='')&&($myrow["description"]=='')&&(strlen(trim($myrow["design"]))>0)){$indescription=$design.' '.$guarantee;}
    elseif((
    $myrow["casework"]=='')&&($myrow["description"]=='')&&($myrow["design"]=='')){$indescription=$design.' '.$guarantee;}
    elseif((
    strlen(trim($myrow["description"])) >1)&&(strlen(trim($myrow["casework"])) >1)){$indescription=$design.' '.$myrow["description"].' in '.$myrow["casework"].'. '.$guarantee;}
    if(
    $myrow["RP"]<261116){$description=$myrow["description"];}else{$description=$indescription;}
    if(
    $myrow["RP"]<261116){$piano=$myrow["make"];}else{$piano=$myrow["make"].' '.$myrow["model"];}
        

    printf("<tr>
            <td>%s</td>
            <td>
    $piano</td>
            <td>%s</td>
            <td>
    $description</td>
            <td>%s</td>
            <td>%s</td>
            <td>
    $showprice</td>
            <td>
    $showdimensions</td>
            <td>%s</td>
            <td><img src=\"image_pull.php?serial=
    $s\"></td>
            </tr>\n"
    ,
            
    $myrow["RP"],
            
    $myrow["ptype"],
            
    $myrow["serial"],
            
    $myrow["year"],
            
    $myrow["location"],
            
    $myrow["serial"]);

      } while (
    $myrow mysql_fetch_array($result));

        echo 
    "</table>\n";

    } else {

        echo 
    "Sorry, no records were found!";    

    }


    mysql_close();

    ?>
    If anyone could help, that would be great.

    Cheers

    Ad
    Don Mullet -
    www.donmullet.com


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
  •