Jump to content

[SOLVED] Form Inserting to mysql then echoing a image from the database to a webpage


Recommended Posts

Heres the process code for the form. I tried to replace $_POST with $_FILES then it put Arrey in the field not the image name.

 

$query = "INSERT into `".$db_table."` (venue,address,date_1,time_1,date_2,time_2,date_3,time_3,date_4,time_4,host,host_email,venue_website,venue_phone,logo_image) VALUES ('" . $_POST['venue'] . "','" . $_POST['address'] . "','" . $_POST['date_1'] . "','" . $_POST['time_1'] . "','" . $_POST['date_2'] . "','" . $_POST['time_2'] . "','" . $_POST['date_3'] . "','" . $_POST['time_3'] . "','" . $_POST['date_4'] . "','" . $_POST['time_4'] . "','" . $_POST['host'] . "','" . $_POST['host_email'] . "','" . $_POST['venue_website'] . "','" . $_POST['venue_phone'] . "','" . $_POST['logo_image'] . "')";
mysql_query($query);

 

thats because the value is still in the database,

 

you could update the if statement to check both,

    if(empty($row['logo_image']) || !file_exists("admin/venues/files/{$row['logo_image']}"))
    {
        echo "<img src='admin/venues/files/noimage.gif'>";  // no image
    }else{
        echo "<img src='admin/venues/files/{$row['logo_image']}'>";  // found image
    }

WORKS THANKS FOR ALL THE HELP MadTechie

This is displaying code from mysql to a <DIV></DIV> on a web page.

Heres the final code hopefully it will help others. Granted youll need to rename fields and stuff but may help

Thanks again MadTechie

$query= 'SELECT venue, address, date_1, time_1, date_2, time_2, date_3, time_3, date_4, time_4, host, host_email, venue_website, venue_phone, logo_image FROM Venues ORDER BY date_1 ASC LIMIT 0, 100';

$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)) {

    if (!empty($row['venue'])) echo "<b>".$row['venue']."</b><br />\n"; 
    if (!empty($row['address'])) echo $row['address']."<br />\n"; 
    if (!empty($row['date_1'])) echo $row['date_1']." ";
    if (!empty($row['time_1'])) echo $row['time_1']."<br />\n"; 
    if (!empty($row['date_2'])) echo $row['date_2']."<br />\n";
    if (!empty($row['time_2'])) echo $row['time_2']."<br />\n"; 
    if (!empty($row['date_3'])) echo $row['date_3']."<br />\n"; 
    if (!empty($row['time_3'])) echo $row['time_3']."<br />\n"; 
    if (!empty($row['date_4'])) echo $row['date_4']."<br />\n"; 
    if (!empty($row['time_4'])) echo $row['time_4']."<br />\n"; 
    if (!empty($row['host'])) echo "Host: ".$row['host']."<br />\n"; 
    if (!empty($row['host_email'])) echo "Host Email: ".$row['host_email']."<br />\n"; 
    if (!empty($row['venue_website'])) echo $row['venue_website']."<br />\n"; 
    if (!empty($row['venue_phone'])) echo $row['venue_phone']."<br />\n"; 

if(empty($row['logo_image']) || !file_exists("directory where images are stored/{$row['logo_image']}"))
    {
        echo "<img src='directory where noimage.gif'is stored>";  // no image
    }else{
        echo "<img src=' directory where images are stored/{$row['logo_image']}'>";  // found image
    }


echo "<hr>";
}

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.