SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast haryoh's Avatar
    Join Date
    Mar 2004
    Location
    Maryland
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    a simple math row_calculation but with un-notice errors

    hi guys,
    this forum have helped me alot especially the last thread i posted,
    Code:
    "Jelena"
    , thanks to you if you are reading this and a friend of mine who knows himself.

    i have this code which calls out all every image_id from a table using fetch_assoc/fetch_array. what i want to do is that there are some fields which do not have image in them and they null and i want to write a statement which will call the ones with no images and assigned a constant image for them while the ones with images show...

    NOW: every image as a link to a page where it shows everything about the picture table and the JOIN table which has full information about the user but the code i wrote won't do that instead, shows the ones with images along with the right links but others a constant image with no link at all
    here is my code which pulls out the whole thing.

    PHP Code:
    $getpic mysql_query("SELECT * FROM images WHERE ID = '$id'")
                    or die(
    mysql_error());
      
    $rows mysql_fetch_assoc($getpic);
      
    $id $rows['ID'];
      
    //extract($rows);<this was used to call out any field name that is
      //present in image table...

      
    $gotpicid "imagev/" $id ".jpg";

      if (!
    $rows) {
            echo(
    "<div class='red'>Image could not be found</div>");
            echo(
    "<tr><td width='90' rowspan='5' valign='top'><a href=javascript:Start('info_show.php?usmotors=$id&$vin&$randnum'); class='cursorBut'>" .
                    
    "<img src='imagev/no_image.jpg' alt='$model$year Series: Click to view' width='100' height='90' border='0'></a></td>");
          } else {

      echo(
    "<tr><td width='90' rowspan='5' valign='top'><a href=javascript:Start('info_show.php?usmotors=$id&$vin&$randnum'); class='cursorBut'>" .
                    
    "<img src='$gotpicid' alt='$model$year Series: Click to view' width='100' height='90' border='0'></a></td>");
    }
      echo(
    "<td height='21' align='left' valign='top'>Make: $vmake</td>");
      echo(
    "<td align='left' valign='top'>Model: $model</td>");
      echo(
    "<tr><td height='21' align='left' valign='top'>Type: $cname</td>" .
            
    "<td align='left' valign='top'>Year: $year </td></tr>");
      echo(
    "<tr><td height='21' align='left' valign='top'>Price: $$price</td>" .
            
    "<td align='left' valign='top'>Mileage: $mileage</td></tr>");
      echo(
    "<tr><td height='21' rowspan='6' align='left' valign='top'>URL:
      <a href=javascript:Start('info_show.php?usmotors=
    $id&$vin&$randnum');>$vmake</a>" .
      
    "</td></tr>");
      echo(
    "<tr><td height='30' rowspan='6' align='left' valign='top' nowrap>Note: $note&nbsp;</td>
      </tr>"
    );
      echo(
    "</table>");



  2. #2
    SitePoint Zealot bensheard's Avatar
    Join Date
    Jun 2006
    Location
    Cape Town | South Africa
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Im not completely sure what you want, but I think you want to give a default image url to all rows that dont have one. If im correct, you could maybe do something like this: (assuming ID is the field that contains the url -- )
    PHP Code:
    $default_url "images/default.jpg";
    mysql_query("UPDATE images SET `ID` = '$default_url' WHERE `ID` = '' || `ID` = null"); 
    If that is what you want then this code will update all the rows in the table that dont contain an image url.
    Ben Sheard
    -------------
    Log all your dives easily and quickly from anywhere in the world
    www.divinglogs.cafe150.com

  3. #3
    SitePoint Enthusiast haryoh's Avatar
    Join Date
    Mar 2004
    Location
    Maryland
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that's cool it's going to work i know for sure but i don't want to update any i just want to define the script to that...

    this is the link of the script..
    http://www.scofieldassociates.com/PHPtest/inventory.php


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
  •