1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

new to php please help

Discussion in 'PHP' started by cdl512, Jul 24, 2006.

  1. #1
    I am working with a template and want to get my images from a url not on my site can i do it from this code?

    function getProductDetail($pdId, $catId)
    {

    $_SESSION['shoppingReturnUrl'] = $_SERVER['REQUEST_URI'];

    // get the product information from database
    $sql = "SELECT pd_name, pd_description, pd_price, pd_image, pd_qty, pd_affurl FROM tbl_product
    WHERE pd_id = $pdId";

    $result = dbQuery($sql);
    $row = dbFetchAssoc($result);
    extract($row);

    $row['pd_description'] = nl2br($row['pd_description']);

    if ($row['pd_image']) {
    $row['pd_image'] = WEB_ROOT . 'images/product/' . $row['pd_image'];
    } else {
    $row['pd_image'] = WEB_ROOT . 'images/no-image-large.png';
    }

    $row['cart_url'] = "cart.php?action=add&p=$pdId";

    return $row;
    }

    Thanks for your help!
     
    cdl512, Jul 24, 2006 IP
  2. danielbruzual

    danielbruzual Active Member

    Messages:
    906
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    70
    #2
    yes, just replace with the url and dir of where the images are located, like so:

    
    
    	if ($row['pd_image']) {
    		$row['pd_image'] = 'http://www.mydomainname.com/images/product/' . $row['pd_image'];
    	} else {
    		$row['pd_image'] = 'http://www.mydomainname.com/images/no-image-large.png';
    	}
    
    
    Code (markup):
    of course, you have to make sure that the images have the same name as on the database.
     
    danielbruzual, Jul 24, 2006 IP
  3. cdl512

    cdl512 Well-Known Member

    Messages:
    125
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
    #3
    thanks but that did not work
     
    cdl512, Jul 24, 2006 IP
  4. cdl512

    cdl512 Well-Known Member

    Messages:
    125
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
    #4
    this is what I put in
    if ($row['pd_image']) {
    $row['pd_image'] = 'http://www.evitamins.com/images/products/' . $row['pd_image'];
    } else {
    $row['pd_image'] = 'http://www.evitamins.com/images/no-image-large.gif';
    }
     
    cdl512, Jul 24, 2006 IP
  5. danielbruzual

    danielbruzual Active Member

    Messages:
    906
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    70
    #5
    
    
    	if ($row['pd_image']) {
    		$row['pd_image'] = 'http\://www.mydomainname.com/images/product/' . $row['pd_image'];
    	} else {
    		$row['pd_image'] = 'http\://www.mydomainname.com/images/no-image-large.png';
    	}
    
    
    Code (markup):
    try that.
     
    danielbruzual, Jul 25, 2006 IP