Quote: $conn=@mysql_connect('localhost','root','') or die ('Not Connected...'); $db=mysql_select_db('project_interior',$conn); $command = isset($_GET['command']) ? $_GET['command'] : 'list'; // $choice=$_POST['category']; switch($command) { case "list": test_table_list(); break; case "add": test_table_add(); break; case "insert": test_table_insert(); break; } function test_table_list() { if(isset($_POST['category'])) { $choice = $_POST['category']; $selQuery = "SELECT * FROM $choice"; $rsQuery = mysql_query($selQuery) or die('Query Not Executed'); $htmlTable = 'Add'; while($rowQuery = mysql_fetch_array($rsQuery)) { $htmlTable .= ''; } $htmlTable .= 'EditDeleteIDPicturePrice' . $rowQuery['id'] . '<img src="' . $rowQuery['snap'] . '" height="150" width="150">' . $rowQuery['price'] . ''; echo $htmlTable; } } function test_table_insert() { if(isset($_POST['category'])) { $choice=$_POST['category']; $price1=$_POST['txtPrice']; $filename=$_FILES['fileSnap']['name']; $path="./images1"; $type=$_FILES['fileSnap']['type']; $str=substr($type,0,5); if($str=="image") { if(move_uploaded_file($_FILES['fileSnap']['tmp_name'],$path."/".$filename)) { $mysql_path=$path."/".$filename; $sql="INSERT INTO $choice(snap,price) VALUES ('$path','$price1')"; if(mysql_query($sql)) { echo "Uploaded successfully..."; test_table_list(); } else { echo "Sorry plz try again..."; } } else { echo "There was an error uploading the file, please try again!"; } } else { echo "select image"; } } } function test_table_add() { ?> <form method="post" action="test_table.php?command=insert"> Picture <input type="file" name="fileSnap"/> Price <input type="text" name="txtPrice"/> <input type="submit" name="btnAdd" value="Add"/> </form> } ?>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)