hi m making a program n i want that when i want to add update a stock it get the name of product from data base and show it in drop down list so that i can select one of them which i want to update. my code for that form in which drop down list is :
now i have made it correct it works perfectly. n says that my query has been executed successfully but it doesnot update my code can anyone tell me what could be the reason
In line 14 the value should be enclosed with quotes ((X)HTML requirement), which should be escaped (since you double quotes are used as string identifiers), elements of an associative array enclosed in {} and associative index enclosed in single quotes:
' ' are not working. "" works and data comes from database and appears in drop down list but now the problem lies that when i select that and make changes those changes donot take affect in database
The problem might then be in add_stock_process.php file which is called upon submitting the form. Post the code of add_stock_process.php so we can help.
Insert the following code after row 17 to check what the query contains:
die(query);
This will display the query in your browser. Then check whether the query contains appropriate values. If yes, copy the displayed query and paste it into phpMyAdmin (or whichever client you use to access your db) to test what it returns. If there are errors correct them or post them here.
One question: shall your query in line 9 not be narrowed to select the quantity for a specific product? Sometnig like:
$sql = "SELECT `quantity` FROM `rpms` WHERE `product_name`='$product_name'";
Your select element is named menu_name while you are using the index product_name in the POST array. Check what the indexes in POST array are in add_stock_process.php. Put something like this at the beginning.
i have got same problem in my other file as well in which i want to create new order. m posting both files now
<?php
session_start();
$con=mysql_connect("localhost","root","");
mysql_select_db("pras2");
?>
<!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">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>Home Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../../../Users/dfff/Documents/Unnamed Site 3/mm_travel2.css" type="text/css" />
<script language="JavaScript" type="text/javascript">
<!--
//--------------- LOCALIZEABLE GLOBALS ---------------
var d=new Date();
var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
//Ensure correct for language. English is "January 1, 2004"
var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
//--------------- END LOCALIZEABLE ---------------
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body bgcolor="#C0DFFD">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#3366CC">
<td colspan="3" rowspan="2"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_travel_photo.jpg" alt="Header image" width="382" height="127" border="0" /></td>
<td height="63" colspan="3" id="logo" valign="bottom" align="center" nowrap="nowrap">insert website name</td>
<td width="4"> </td>
</tr>
<tr bgcolor="#3366CC">
<td height="64" colspan="3" id="tagline" valign="top" align="center">OPTIONAL TAGLINE HERE</td>
<td width="4"> </td>
</tr>
<tr>
<td colspan="7" bgcolor="#003366"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
</tr>
<tr bgcolor="#CCFF99">
<td colspan="7" id="dateformat" height="25"> <script language="JavaScript" type="text/javascript">
document.write(TODAY); </script> </td>
</tr>
<tr>
<td colspan="7" bgcolor="#003366"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
</tr>
<tr>
<td width="165" valign="top" bgcolor="#E6F3FF">
<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165">
</td>
</tr>
<tr>
<td width="165"><a href="javascript:;" class="navText">destinations</a></td>
</tr>
<tr>
<td width="165"><a href="javascript:;" class="navText">airfare</a></td>
</tr>
<tr>
<td width="165"><a href="javascript:;" class="navText">cruises</a></td>
</tr>
<tr>
<td width="165"><a href="javascript:;" class="navText">specials</a></td>
</tr>
<tr>
<td width="165"><a href="javascript:;" class="navText">contact</a></td>
</tr>
</table>
</td>
<td width="50"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="50" height="1" border="0" /></td>
<td colspan="2" valign="top"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="305" height="1" border="0" />
<table border="0" cellspacing="0" cellpadding="0" width="685">
<tr>
<td width="685" class="pageName"><div align="center">NEW ORDER </div></td>
</tr>
<tr>
<td class="bodyText"><p>To place a new order</p>
<p> </p>
<form name="form1" id="form1" action="order_entering.php">
Select a product you want to choose:
<?php
$query="SELECT product_id,product_name FROM product";
$result = mysql_query ($query);
echo '<select name="product_name" value="">';
echo "<option>";
if($result)
{while($menu=mysql_fetch_assoc($result)){
echo "<option value=$menu[product_name]>$menu[product_name]</option>"; }
echo "</select>";
}
else
{
echo" failed";
}
?>
</p>
<p> </p>
<p>Enter the amount of product you want:
<label>
<input type="text" name="quantity" />
</label>
(It should not be less than 2000pieces) </p>
<p>
<label></label>
<input type="submit" name="Submit2" value="Submit order" />
</p>
<p> </p>
<p> </p>
<p>
<label></label>
</p>
<p> </p>
</form>
<p> </p>
<p> </p></td>
</tr>
</table>
</td>
<td width="50"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="50" height="1" border="0" /></td>
<td width="190" valign="top">
<table border="0" cellspacing="0" cellpadding="0" width="190">
<tr>
<td colspan="3" class="subHeader" align="center">NEW DESTINATIONS</td>
</tr>
<tr>
<td width="40"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="40" height="1" border="0" /></td>
<td width="110" id="sidebar" class="smallText">
<p><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_travel_photo1.jpg" alt="Image 1" width="110" height="110" vspace="6" border="0" />
Include a short description here.
<a href="javascript:;">Read more ></a></p>
<p><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_travel_photo2.jpg" alt="Image 2" width="110" height="110" vspace="6" border="0" />
Include a short description here.
<a href="javascript:;">Read more ></a></p>
</td>
<td width="40"> </td>
</tr>
</table> </td>
<td width="4"> </td>
</tr>
<tr>
<td width="165"> </td>
<td width="50"> </td>
<td width="167"> </td>
<td width="486"> </td>
<td width="50"> </td>
<td width="190"> </td>
<td width="4"> </td>
</tr>
</table>
</body>
</html>
<?php
?>
this was the code of form and now the code for its processing is;
<?php
session_start();
print_r($_POST);
$name=$_SESSION['SESS_CUSTOMER_ID'];
$con=mysql_connect("localhost","root","");
mysql_select_db("pras2");
$product_id=$_POST['product_name'];
echo "$product_id";
$quantity=$_POST['quantity'];
$query= "INSERT INTO order (customer_id, product_id, quantity) VALUES ('$name', '$product_id', '$quantity')";
die($query);
$result=mysql_query($query);
if ($result)
{
echo " Your order has been passed to admin for acceptance/rejection";
}
else
{
echo " failed";
}
?>
Seems like order_entering.php script is not getting correct values in the POST array. Have you checked what is contained in the $_POST array (as I suggested insert the print_r($_POST) line in the beginning of the second script and tell us what it displays)?