Jump to content

Sending form values to mysql


KeeganWolf

Recommended Posts

I have a script that creates a form from values in a table, but I can't get it to save those values to the table on submit. Heres what I have

 

<?php
// Make a MySQL Connection
include_once "../scripts/connect_to_mysql.php";

// Create a page with the specified table info

$store = "4071";
$local = "WF";
$query = "SELECT * FROM Inventory$store WHERE local='$local'";
echo "<table width=800 border=1 align=center><tr>";
echo "<td width=200><strong>Store: ", $store, "</strong></td>";
echo "<td width=584><strong>Step 1. Walk In Freezer</strong></td></tr></table><p><br /></p>";

$result = mysql_query($query) or die(mysql_error());
$content = <<<CONT
<table border="1" align="center">
<tr>
<th>Product ID</th>
<th>Description</th>
<th>Quantity</th>
<th>Case</th>
<th>Build2</th>
</tr>
CONT;

while($row = mysql_fetch_array($result)){
$content .= <<<CON
<form method='post' action='proc_print.php'>
<tr>
<td>{$row['fomez']}</td>
<td>{$row['desc']}</td>
<td><input type='text' name='quant' value='{$row['quant']}'></td>
<td>{$row['quancase']}</td>
<td><input type='text' name='buil2' value='{$row['buil2']}'></td>
</tr>
CON;
}
$content .= "</table>";
echo $content;
echo "<input type='submit' value='Continue to the next step.'></form>\n";
/// print_r($case);
?>

 

And this file proc_print.php

 

<?php
// Make a MySQL Connection
include_once "../scripts/connect_to_mysql.php";

$quant = $_REQUEST['quant'];
$buil2 = $_REQUEST['buil2'];
/***********************************************/
$case = addslashes($case);
$case = htmlentities($case);
$buil2 = addslashes($case);
$buil2 = htmlentities($case);
/***********************************************/
$deduct = "UPDATE Inventory4071 SET quant='$quant' WHERE fomez=fomez LIMIT 1";
mysql_query($deduct) or die("Error: " . mysql_error() . "<br />" . $deduct );
echo $deduct;
//if (mysql_query("UPDATE Inventory4071 SET quant='$quant' WHERE fomez=fomez LIMIT 1;")) {
//echo "success";
//}else{
//echo "failed";
//}

?>

 

The form is generated correctly, but when submitted, only the first value 'quant' is saved to the first item listed.

Link to comment
https://forums.phpfreaks.com/topic/160678-sending-form-values-to-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.