Insert data query
Posted: Tue Feb 22, 2005 5:27 pm
Hye I'm trying to take a value from a select query and put that value into an insert query. at the moment everything but the select query result is being inserted.
the code i'm using is as follows
My Inital form where the user inputs there selection
My processing script where the select and insert script is
Can anyone advise me on where i'm going wrong. The problem is the Insert statement, wont display anything for $result.
Does anyone maybe have a better solution?
I'm new to php so please dont get too technical with me, lol
regards
Shab
the code i'm using is as follows
My Inital form where the user inputs there selection
Code: Select all
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="processorder.php">
<p>
<label> </label>
<br>
<label>
<input type="radio" name="RadioGroup1" value="1125">
Beans
</label>
<br>
<label>
<input type="radio" name="orderlist" value="12">
Tuna Mayo Bagutte</label>
<br>
<label>
<input type="radio" name="orderlist" value="13">
Tuna Salad</label>
<br>
<input type="radio" name="orderlist" value="11">
Special <br>
<input type="text" name="comments">
Comments </p>
<p>
<input type="text" name="quantity">
Quantity </p>
<p>
<input type="text" name="username">
Username</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>Code: Select all
<?php
$item_id=$_POSTї'orderlist'];
$comments=$_POSTї'comments'];
$quantity=$_POSTї'quantity'];
$user_name=$_POSTї'username'];
$hostname="localhost";
$mysql_login="root";
$mysql_password="******";
$database="coachhouse";
$connect = mysql_connect("$hostname", "$mysql_login" , "$mysql_password");
$table_name = emp_order;
$result = mysql_query ("SELECT item_description from item where item_id = '$item_id'",$connect);
$query = ("INSERT INTO emp_order VALUES ('','$result','$quantity','$comments','$user_name')");
mysql_query($query);
mysql_select_db($database);
PRINT '<br><font size ="4" colour="blue">';
IF (mysql_query($query))
PRINT "<center>Order Has Been Placed</Center></font><BR><BR>";
mysql_close($connect);
?>Does anyone maybe have a better solution?
I'm new to php so please dont get too technical with me, lol
regards
Shab