I have a very small database in MySQL. There are 20 columns, all text. My PHP script loads all this data into an array and assigns each value to a variable. One of the varibles is $ID_num which contains a unique identifier that is also tied to an image in a web folder. What I need to do is display all the data in tables on a web page. That is already complete. One of the cells in the table will contain the image tied to that identifier.

For example:

One of the values from the ID-number column ion the database table is 1654848. In the web folder is an image labeled 1654848.jpg

In PHP I use "SELECT * from table; and load the results into an array using while statement. When I populate the html table with the variables, I need to state the url to where the image is kept (localhost\htdocs\image_folder\xxxxx.jpg
where xxxxx is the same value as $ID-num variable.

Is the a way to build that url with something like 'http://localhost/htdocs/image_folder' + '$ID-num'.'jpg'

Any help or suggestions would be appreciated.

<?php
    // connection details
    // connection details

    $sql = "SELECT * FROM {table}";
    $result = mysql_query($sql) or die(mysql_error());
    if(mysql_affected_rows() >= 1)
    {
        while($row = mysql_fetch_array($result))
        {
            $image_url = $row['url'];
        }

        echo "http://localhost/htdocs/image_folder" . $image_url . ".jpg";

    }
?>

Have not tested it, should give you a rough idea :)!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.