putting image in php

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

  1. #1
    I am having trouble getting an image from a url to show in a simple php code, any tips?
     
    cdl512, Jul 19, 2006 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    What is the code you are having problems with?
     
    jestep, Jul 19, 2006 IP
  3. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #3
    I don't fully understand your question.

    You want to get an image from a url, you will need to open the url and fetch the HTML then use regular expressions to find the image you want.

    Peace,
     
    Barti1987, Jul 19, 2006 IP
  4. cdl512

    cdl512 Well-Known Member

    Messages:
    125
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
    #4
    I am working on a php site, my first and have some problems.

    1. creating individual page for each item
    2. showing image from url
    3. creating link for purchase with my aff link
    4. i want to mask the link if I can to avoid any posible search engine trouble and from hijacking

    here is my basic code:
    <?php
    //Connect to the mysql server and get back our link_identifier
    $link = mysql_connect("", "", "")
    or die('Could not connect: ' . mysql_error());


    //Now we select which database we would like to use
    mysql_select_db("") or die('could not select database');
    include ('header');

    //Our SQL Query
    $sql_query = "Select Name, Description, Price, LinkURL, ImageURL, Category FROM example ORDER BY Category";

    //Run our sql query
    $result = mysql_query($sql_query)or die('query failed'. mysql_error());
    echo '<table border=0 bgcolor=#E6E6E6 align=left width="50" border="0" cellpadding=4 cellspacing=0>

    <tr><td align="left"<b>Category</b>
    <td align="left"><b>Name</b></td>
    <td align="left"<b>Description</b></td>
    <td align="left"<b>Price</b></td>
    <td align="left"<b>Buy</b></td>
    <td align="left"<b>Image</b>
    </td></tr>
    ';
    //iterate through result
    while($row = mysql_fetch_array
    ($result, MYSQL_ASSOC)) {
    echo '<tr><td align=
    "left">' . $row['Category'] .'</td><td align="left">' .
    $row['Name'] , '</td><td align=
    "left">' . $row['Description'] .'</td><td align=
    "left">' . $row['Price'] .'</td><td align=
    "left">' . $row['LinkURL'] .'</td><td align=
    "left">' . $row['ImageURL'] .'</td>
    </tr>
    ';
    }
    echo '</table>';



    // Free resultset (optional)
    mysql_free_result($result);


    //Close the MySQL Link
    mysql_close($link);
    include ('footer');
    ?>

    I also have a left column for categories etc.
     
    cdl512, Jul 19, 2006 IP
  5. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If your database stores the image like http://www.site.com/image.jpg then you would need to echo
     
    mad4, Jul 19, 2006 IP