I am creating a user panel in which users can register and upload a image. Once they login they may decide to edit that image therefore I am wanting to perform a update query to add a new image to the location and attach the new image to their mysql data.
So whats happening when i submit the code: I get a error saying:: Sorry, there was a problem uploading your file.
Hopefully someone can let me know why this is giving me a error. PS I am already using this location when they first register to upload a file. But surely this shouldnt have any problem. Another issue i found is that nothing is being successfully inserted into the MYSQL Table for the photo.
So here is the code:
Table: admin
CREATE TABLE IF NOT EXISTS `admin` (
`id` int(3) NOT NULL auto_increment,
`UserName` varchar(30) default NULL,
`PassWord` varchar(30) default NULL,
`name` varchar(30) default NULL,
`mainContent` varchar(2000) default NULL COMMENT 'maincontent test',
`photo` varchar(400) NOT NULL COMMENT 'Picture1',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=64 ;
So lets imagine the user has logged into their user panel: and they click the edit button linking to their ID.
So they appear at the edit page:
EDIT.PHP
<?php
session_start();
$UserName = $_SESSION['UserName'];
require("checkLoginSession.php");
$adminid = $_GET['id'];
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
echo("Logged In As: $UserName");
echo "<br />";
echo("We are editing Data for ID: $adminid");
echo "<br />";
echo "<a href=test.php>Go back to panel</a>";
$id=$_GET['id'];
// Retrieve data from database
$sql="SELECT * FROM admin WHERE id='$id'";
$result=mysql_query($sql) or die(mysql_error());
$rows=mysql_fetch_array($result);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<form name="form1" method="post" action="update_ac.php">
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td> </td>
<td colspan="3"><strong>Update data in mysql</strong> </td>
</tr>
<tr>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
</tr>
<tr>
<td align="center"> </td>
<td align="center"><strong>Name</strong></td>
<td align="center"><strong>Main Content</strong></td>
<td align="center"><strong>Image Locatoin</strong></td>
</tr>
<tr>
<td> </td>
<td align="center"><input name="name" type="text" id="name" value="<? echo $rows['name']; ?>"></td>
<td align="center"><input name="mainContent" type="text" id="mainContent" value="<? echo $rows['mainContent']; ?>" size="15"></td>
<td align="center"><input name="photo" type="file" id="photo">
</tr>
<tr>
<td> </td>
<td><input name="id" type="hidden" id="id" value="<? echo $rows['id']; ?>"></td>
<td align="center"><input type="submit" name="Submit" value="Submit"></td>
<td> </td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<?
mysql_close();
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Edit Page</title>
</head>
<body>
<h2>Edit Page (<?php echo ("$adminid"); ?>)</h2>
<img src="backtopanel.jpg" alt="back to panel" width="454" height="85" border="0" longdesc="back to panel" />
</body>
</html>
update_ac.php
<?php
session_start();
$UserName = $_SESSION['UserName'];
require("checkLoginSession.php");
include "common.php";
DBConnect();
$Link = mysql_connect($Host, $User, $Password);
$id = $_POST['id'];
$target = "images/";
$target = $target . basename( $_FILES['photo']['name']);
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// update data in mysql database
$_POST = array_map("mysql_real_escape_string", $_POST);
$firstName = $_POST["name"];
$mainText = $_POST["mainContent"];
$pic=($_FILES['photo']['name']);
//
$sql="UPDATE admin SET name='$firstName', mainContent='$mainText', photo='$pic' WHERE id='$id'";
echo $sql;
//
if (mysql_db_query ($DBName, $sql, $Link)){
print ("A record was created <br><a href=index.php> return to index </a>\n");
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
} else {
print ("Record not created");
}
mysql_close($Link);
?>
A few things:
If nothing is coming through in $_FILES then you have probably missed out enctype="multipart/form-data" in the form tag of the submitting page where the image is being specified.
When handling the uploaded file you need to use $_FILES['inputName']['tmp_name'] to get the temp location of the file then move this using move_uploaded_file($_FILES['inputName']['tmp_name'], 'destination'); and store the destination value in the DB record.
On the edit page where you want to display the image you will need to have the image itself displayed (using and img tag) as well as a file input for changing the image if required.
I could go on, but I really think you need to go read some tutorials on form / file handling in PHP as would most which is why you have not received any replies...
Related
I try to use the below code to update multiple rows, the below code can view the results of rows but it can not be updated, where is wrong place? How to modify it ?
<?php
$host="localhost"; // Host name
$username="abc"; // Mysql username
$password="abc123"; // Mysql password
$db_name="abc"; // Database name
$tbl_name="BRAddress"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("Cannot connect");
mysql_select_db("$db_name")or die("Cannot select Database");
$sql="SELECT * FROM $tbl_name WHERE br_no='62779457'";
$result=mysql_query($sql);
// Count table rows
$count=mysql_num_rows($result);
?>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<form name="form1" method="post" action="">
<tr>
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="center"><strong>BR No.</strong></td>
<td align="center"><strong>Date of Register</strong></td>
<td align="center"><strong>Address</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center">
<? $br_no[]=$rows['br_no']; ?><? echo $rows['br_no']; ?>
</td>
<td align="center">
<input name="br_date_of_register[]" type="date" id="br_date_of_register" value="<? echo $rows['br_date_of_register']; ?>">
</td>
<td align="center">
<input name="br_address[]" type="text" size="60" id="br_address" value="<? echo $rows['br_address']; ?>">
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="3" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
<?php
// Check if button name "Submit" is active, do this
if($Submit){
for($i=0;$i<$count;$i++){
$sql1="UPDATE $tbl_name SET
br_date_of_register='$br_date_of_register[$i]',
br_address='$br_address[$i]'
WHERE br_no='$br_no[$i]'";
$result1=mysql_query($sql1);
}
}
if($result1){
header("location:update_sample.php");
}
mysql_close();
?>
Thank you very much for your help & support !
I think that you need to change this part
if($Submit){
to
if($_POST('Submit')){
I haven't run the whole or looked at entire code, but you have nothing that defines $Submit variable though from what I see.
Or you can put in
$Submit = $_POST('Submit');
before the if statement.
Let me know how you go.
Cheers
Your POST variable are empty. $br_date_of_register has no value. You must use this like following
$br_date_of_register = $_POST[br_date_of_register];
$br_address = $_POST[br_address];
for($i=0;$i<$count;$i++){
$sql1="UPDATE $tbl_name SET
br_date_of_register='$br_date_of_register[$i]',
br_address='$br_address[$i]'
WHERE br_no='$br_no[$i]'";
$result1=mysql_query($sql1);
}
Edit
if($Submit)
To
if($_SERVER['REQUEST_METHOD'] == "POST")
Considering your Submit check,
you can use this,
if(isset($_POST["Submit"]))
{
}
Further in your SQL statement, do this,
$sql1='UPDATE ' . $tbl_name . ' SET
br_date_of_register = ' . $br_date_of_register[$i] .
' , br_address = ' . $br_address[$i] .
' WHERE br_no = ' . $br_no[$i];
I have created a simple web form in which you input data into and then it is posted into the database, when submitting the information it is submitted correctly but when I view it in the table the data is invisible.
query
CREATE TABLE `recipe` (
`id` int(4) NOT NULL auto_increment,
`recipename` varchar(65) NOT NULL default '',
`ingredients` varchar(65) NOT NULL default '',
`instructions` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=0 ;
php code
<?php
$host="localhost"; // Host name
$username="my username"; // Left empty due to privacy
$password="mypassword"; // Left empty due to privacy
$db_name="mydatabase"; // Left empty due to privacy
$tbl_name="recipe"; // Table name
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$recipe=$_POST['recipename'];
$ingredients=$_POST['ingredients'];
$instructions=$_POST['instructions'];
$sql="INSERT INTO $tbl_name(recipename, ingredients, instructions)VALUES('$recipe', '$ingredients', '$instructions')";
$result=mysql_query($sql);
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='recipe.php'>Back to main page</a>";
} else {
echo "ERROR";
}
?>
<?php
// close connection
mysql_close();
?>
Web Form
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td>
<form name="form1" method="post" action="insert_ac.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td colspan="3"><strong>Insert Data Into mySQL Database </strong></td>
</tr>
<tr>
<td width="71">Recipe name</td>
<td width="6">:</td>
<td width="301"><input name="name" type="text" id="recipe"></td>
</tr>
<tr>
<td>Ingredients</td>
<td>:</td>
<td><input name="lastname" type="text" id="ingredients"></td>
</tr>
<tr>
<td>Instructions</td>
<td>:</td>
<td><input name="email" type="text" id="instructions"></td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
I would love to know if anyone knows the reason the data is invisible.
Image of table with no data
$recipe=$_POST['recipename'];
$ingredients=$_POST['ingredients'];
$instructions=$_POST['instructions'];
needs to be:
$recipe=$_POST['name'];
$ingredients=$_POST['lastname'];
$instructions=$_POST['email'];
You have the form field names wrong, so it is not getting a value and thus inserting empty data. If you set error_reporting to E_ALL you would have gotten an error. Make sure you develop with it at that setting.
Also the name attribute in the form field is what the index name would be for $_POST['INDEX_NAME'], you are mistakingly using the id attribute for that.
I need to make my form field not required when uploading information. Here is the scenario and code:
Scenario: A user wants to edit their information, without updating a different image: But obviously when i click submit and leave the image field blank it throws a error, how can i prevent this.
The field i want to be not required is the Image field (photo)
Here is code:
<?php
session_start();
$UserName = $_SESSION['UserName'];
require("checkLoginSession.php");
$adminid = $_GET['id'];
//removed connection
$tbl_name="admin"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
echo("Logged In As: $UserName");
echo "<br />";
echo("We are editing Data for ID: $adminid");
echo "<br />";
echo "<a href=test.php>Go back to panel</a>";
$id=$_GET['id'];
// Retrieve data from database
$sql="SELECT * FROM admin WHERE id='$id'";
$result=mysql_query($sql) or die(mysql_error());
$rows=mysql_fetch_array($result);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<form enctype="multipart/form-data" name="form1" method="post" action="update_ac.php">
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td> </td>
<td colspan="3"><strong>Update data in mysql</strong> </td>
</tr>
<tr>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
</tr>
<tr>
<td align="center"> </td>
<td align="center"><strong>Name</strong></td>
<td align="center"><strong>Main Content</strong></td>
<td align="center"><strong>Image Locatoin</strong></td>
</tr>
<tr>
<td> </td>
<td align="center"><input name="name" type="text" id="name" value="<? echo $rows['name']; ?>"></td>
<td align="center"><input name="mainContent" type="text" id="mainContent" value="<? echo $rows['mainContent']; ?>" size="15"></td>
<td align="center"><input name="photo" type="file" id="photo">
</tr>
<tr>
<td> </td>
<td><input name="id" type="hidden" id="id" value="<? echo $rows['id']; ?>"></td>
<td align="center"><input type="submit" name="Submit" value="Submit"></td>
<td> </td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<?
mysql_close();
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Jonathon Legg - University Year Book - Edit Page</title>
</head>
<body>
<h2>Edit Page (<?php echo ("$adminid"); ?>)</h2>
<img src="backtopanel.jpg" alt="back to panel" width="454" height="85" border="0" longdesc="back to panel" />
</body>
</html>
And here is the update_acknowledge.php
<?php
session_start();
$UserName = $_SESSION['UserName'];
require("checkLoginSession.php");
include "common.php";
DBConnect();
$Link = mysql_connect($Host, $User, $Password);
//connection removed for stack overflow //
$tbl_name="admin"; // Table name
$target = "images/";
$target = $target . basename( $_FILES['photo']['name']);
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// update data in mysql database
$_POST = array_map("mysql_real_escape_string", $_POST);
$firstName = $_POST["name"];
$mainText = $_POST["mainContent"];
$pic=($_FILES['photo']['name']);
//
$sql="UPDATE admin SET name='$firstName', mainContent='$mainText', photo='$pic' WHERE id='$id'";
//
if (mysql_db_query ($DBName, $sql, $Link)){
print ("A record was created <br><a href=index.php> return to index </a>\n");
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
} else {
print ("Record not created");
}
mysql_close($Link);
?>
Just wrap in an 'if' statement...
if (!empty($_FILES['photo']['name'])) {
$pic=mysql_real_escape_string($_FILES['photo']['name']);
$sql="UPDATE admin SET name='$firstName', mainContent='$mainText', photo='$pic' WHERE id='$id'";
} else {
$sql="UPDATE admin SET name='$firstName', mainContent='$mainText' WHERE id='$id'";
}
... of course need a similar if statement on the move_uploaded_file block too.
I have placed the image logic in a conditional if($_FILES['photo']['error'] == 0)
<?php
session_start();
$UserName = $_SESSION['UserName'];
require("checkLoginSession.php");
include "common.php";
DBConnect();
$Link = mysql_connect($Host, $User, $Password);
//connection removed for stack overflow //
$tbl_name="admin"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// update data in mysql database
$_POST = array_map("mysql_real_escape_string", $_POST);
$firstName = $_POST["name"];
$mainText = $_POST["mainContent"];
//
$sql = "UPDATE admin SET name='$firstName', mainContent='$mainText'";
if($_FILES['photo']['error'] == 0) {
$target = "images/";
$target = $target . basename( $_FILES['photo']['name']);
$pic=($_FILES['photo']['name']);
$sql .= ", photo='$pic'";
}
$sql .= "WHERE id='$id'";
//
if (mysql_db_query ($DBName, $sql, $Link)) {
print ("A record was created <br><a href=index.php> return to index </a>\n");
if($_FILES['photo']['error'] == 0) {
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) {
//Tells you if its all ok
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
} else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
}
} else {
print ("Record not created");
}
mysql_close($Link);
?>
i am trying to update my table with the correct information linking to the follwing ID. I will have posted the code so you can all take a look.
Here is my problem: Once i submit the form with all the details recieved from the database, everything works successfull. But when i click submit it re-directs to my other page called update_ac.php. Everything works fine, apart from the data in the mysql tables do not get updated.
I wonder if anyone could take a look at the code to see what they think:much appreciated and feedback would be fantastic. PS I am not the best PHP programmer, still learning!
So here is edit.php - where teh user edits their information:
<?php
session_start();
$UserName = $_SESSION['UserName'];
require("checkLoginSession.php");
$adminid = $_GET['id'];
//CONNECTION CODE WAS HERE
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
echo("Logged In As: $UserName");
echo "<br />";
echo("We are editing Data for ID: $adminid");
echo "<br />";
echo "<a href=test.php>Go back to panel</a>";
$id=$_GET['id'];
// Retrieve data from database
$sql="SELECT * FROM admin WHERE id='$id'";
$result=mysql_query($sql) or die(mysql_error());
$rows=mysql_fetch_array($result);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<form name="form1" method="post" action="update_ac.php">
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td> </td>
<td colspan="3"><strong>Update data in mysql</strong> </td>
</tr>
<tr>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
</tr>
<tr>
<td align="center"> </td>
<td align="center"><strong>Name</strong></td>
<td align="center"><strong>Main Content</strong></td>
</tr>
<tr>
<td> </td>
<td align="center"><input name="name" type="text" id="name" value="<? echo $rows['name']; ?>"></td>
<td align="center"><input name="mainContent" type="text" id="mainContent" value="<? echo $rows['mainContent']; ?>" size="15"></td>
</tr>
<tr>
<td> </td>
<td><input name="id" type="hidden" id="id" value="<? echo $rows['id']; ?>"></td>
<td align="center"><input type="submit" name="Submit" value="Submit"></td>
<td> </td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<?
mysql_close();
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Edit Page</title>
</head>
<body>
<h2>Edit Page (<?php echo ("$adminid"); ?>)</h2>
</body>
</html>
And here is the update_ac.php:
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// update data in mysql database
$firstName = $_POST["name"];
$mainText = $_POST["mainContent"];
$sql="UPDATE admin SET name='$firstName', mainContent='$mainText' WHERE id='$id'";
$result=mysql_query($sql) or die(mysql_error());;
// if successfully updated.
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='test.php'>Back to panel</a>";
}
else {
echo "ERROR";
}
?>
OK GUYS EDIT HERE:
If in the Update_ac.php if i change the following line to this:
$sql="UPDATE admin SET name='$firstName', mainContent='$mainText' WHERE id='1'";
The information now gets updated, therefore means something is going wrong with my ID variable
Looks like the typical omission of database escaping. You need to apply mysql_real_escape_string on any string that you concat in your sql query.
The lazy version is:
$_POST = array_map("mysql_real_escape_string", $_POST);
$firstName = $_POST["name"];
$mainText = $_POST["mainContent"];
Otherwise you will oftentimes get an invalid syntax error. Use print mysql_error(); after the query to find out what went wrong in your case.
See also String escaping for each database or read up on pdo for less fiddly database interaction.
From just a quick glance, it's because you are using variables and not the $_POST variables
$sql="UPDATE admin SET name='$firstName', mainContent='$mainText' WHERE id='$id'";
Should be the post variables with the names of your form fields
$sql="UPDATE admin SET name='$_POST['firstName'], mainContent='$_POST['mainText']' WHERE id='$_POST['id']'";
If you then put your $id variable within a hidden input field within your form, that file will also pick it up.
Just a quick answer cos' I'm out to get lunch.
It is just a syntax error in the update_ac.php
You used 2 semicolons in the following line
$result=mysql_query($sql) or die(mysql_error());;
could anyone look this code over and tell me why it doesnt update the database? I know its hacked together, I am a novice at PHP
thanks in advance
<?php
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name WHERE depot = 'plainview'";
$result=mysql_query($sql);
// Count table rows
$count=mysql_num_rows($result);
//update
if(isset($_POST['Submit'])){
for($i=0;$i<$count;$i++){
$sql1 = "UPDATE $tbl_name SET
available='{$_POST['available'][$i]}',
rent='{$_POST['rent'][$i]}',
corp_ready='{$_POST['corp_ready'][$i]}',
down='{$_POST['down'][$i]}',
gfs='{$_POST['gfs'][$i]}',
dateTime = NOW()
WHERE id='$id[$i]'";
$result1 = mysql_query($sql1) or die(mysql_error());
}
}
//redirect
if($result1){
header("location: plainview.php");
}
mysql_close();
?>
======================
entire code
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name WHERE depot = 'plainview'";
$result=mysql_query($sql);
// Count table rows
$count=mysql_num_rows($result);
//update
if(isset($_POST['Submit'])){
for($i=0;$i<$count;$i++){
$sql1 = "UPDATE $tbl_name SET
available='".mysql_real_escape_string($_POST['available'][$i])."',
rent='".mysql_real_escape_string($_POST['rent'][$i])."',
corp_ready='".mysql_real_escape_string($_POST['corp_ready'][$i])."',
down='".mysql_real_escape_string($_POST['down'][$i])."',
gfs='".mysql_real_escape_string($_POST['gfs'][$i])."',
dateTime = NOW()
WHERE id='".$id[$i]."'";
$result1 = mysql_query($sql1) or die(mysql_error());
}
}
//redirect
if($result1){
header("location: plainview.php");
}
mysql_close();
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script language="JavaScript1.1" type="text/javascript">
<!--
function mm_jumpmenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<title>Untitled Document</title>
</head>
<body>
<div>
<p>Plainview, North East Region</p>
<p>Select a different region: <select onchange="mm_jumpmenu('parent',this,0)" name="lostlist">
<option value="" selected="selected">Choose Your Depot</option>
<option value="plainview.php">Plainview</option>
<option value="worcrester.php">Worcrester</option>
</select></p>
</div><Br />
<table width="500" border="0" cellspacing="1" cellpadding="0">
<form name="form1" method="post" action="">
<tr>
<td>
<table width="700" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>ID</td>
<td align="center"><strong>Product Name</strong></td>
<td align="center"><strong>Available</strong></td>
<td align="center"><strong>Rent</strong></td>
<td align="center"><strong>Corp Ready</strong></td>
<td align="center"><strong>Down</strong></td>
<td align="center"><strong>GFS</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="left"><?php $id[]=$rows['id']; ?><?php echo $rows['id']; ?></td>
<td align="left"><?php echo $rows['product']; ?></td>
<td align="center"><input name="available[]" type="text" id="available" value="<?php echo $rows['available']; ?>" size="5"></td>
<td align="center"><input name="rent[]" type="text" id="rent" value="<?php echo $rows['rent']; ?>" size="5"></td>
<td align="center"><input name="corp_ready[]" type="text" id="corp_ready" value="<?php echo $rows['corp_ready']; ?>" size="5"></td>
<td align="center"><input name="down[]" type="text" id="down" value="<?php echo $rows['down']; ?>" size="5" /></td>
<td align="center"><input name="gfs[]" type="text" id="gfs" value="<?php echo $rows['gfs']; ?>" size="5"></td>
</tr>
<?php
}
?>
<tr>
<td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
<?php
echo "$sql1";
?>
</body>
</html>
Try echo "id='$id[$i]'<br />"; and see if you are getting the ID's that should be sent.
Always escape all user input. Your update query should look like
$sql1 = "UPDATE $tbl_name SET
available='".mysql_real_escape_string($_POST['available'][$i])."',
rent='".mysql_real_escape_string($_POST['rent'][$i])."',
corp_ready='".mysql_real_escape_string($_POST['corp_ready'][$i])."',
down='".mysql_real_escape_string($_POST['down'][$i])."',
gfs='".mysql_real_escape_string($_POST['gfs'][$i])."',
dateTime = NOW()
WHERE id='".$id[$i]."'";
Has $tbl_name been set outside of the code you've provided? If not, set it so your sql knows what table to work with.