Jump to content

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


big-dog1965

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>";
}

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.