0
我創建了一個下拉列表,其中我從一個表'category'(它有兩列cat_id和類別名稱)中提取數據,我想要插入列值另一個表畫廊..我很能獲取CAT_ID但無法獲取類別名稱..please help..SQL注射不是問題從下拉提取列值並將其插入到另一個表中
<?php
include_once("header.php");
include ("connection.php");
if(isset($_REQUEST['ansave']))
{
$a=$_REQUEST['choosecategory'];
$image=$_FILES['uploadgallery']['name'];// name given in input type
$ext=substr(strchr($image,'.'),1);//it breaks the string in part so that format can be matched
if($ext!='jpg' && $ext!='jpeg' && $ext!='png' && $ext!='gif' && $ext!='JPG' && $ext!='JPEG')
{
echo "please select image";
}
else
{
$path="gallery/".$image; //folder in which image to be saved
$action=copy($_FILES['uploadgallery']['tmp_name'],$path);//name given in input type (line72)
$query="insert into gallery (`cat_id`,`galimage`) values('$a','$image')";
$result=mysql_query($query);`enter code here`
echo "insert successfully";
}
}
?>
<option selected> -- select -- </option>';
<?php $sql = "SELECT * FROM category";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result)){
echo '<option value="'.$row['cat_id'].'">'.$row['categoryname'].'</option>';
}
?>
不知道我理解這個問題。在創建下拉菜單時,您是否遇到了獲取類別名稱的問題,或者在用戶上傳圖像時插入了類別ID? – Barmar
http://stackoverflow.com/questions/16514594/in-php-and-jquery-make-one-drop-down-depend-on-another-drop-down-list – user2615302
@Barmar是它與提取類別名 – user2819264