blui Posted March 17, 2007 Share Posted March 17, 2007 Hi all, I am very new to all this so can someone please point me in the right direction. I am developing a site where users can upload images which are automatically resized and stored in a specfic directory. The user then needs to be able to select which image they wish to have shown on there website today. I have managed to get a dynamically created dropdown list showing all of teh files with the directory. But I do not know how to get that selected choice saved on to the database so that a specific webpage, can call the image the user selected. I have included my script showing teh dropdown menu below, any help will be greatly appreciated. Thanks blu <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <? require_once('connectionlocal.php'); ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="post" action="..postinfo2.php"> <label>Choose your image <select name="imagelist"> <? $file_dir="images"; $dir=opendir($file_dir); while ($file=readdir($dir)) { if ($file != "." && $file != "..") { echo "<option value=".$file_dir."/".$file." >".$file.""; echo "<br></option>"; } } ?> </select> </label> <input name="submit" type="button" value="submit" /> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/43107-uploading-selected-choice-from-dropdown-menu-to-database/ Share on other sites More sharing options...
shaunrigby Posted March 17, 2007 Share Posted March 17, 2007 <? $sql = "INSERT INTO `table`(`indeximage`) VALUES (`" . mysql_escape_string($_POST['imagelist']) . "`) LIMIT 1"; $queryResult = mysql_query($sql) or die("An error has happened: " . mysql_error()) Link to comment https://forums.phpfreaks.com/topic/43107-uploading-selected-choice-from-dropdown-menu-to-database/#findComment-209389 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.