Hi I'm not sure wher I am going wrong.
I've borrowed some code and tweaked it.
The database table consists of
id,dates,day,type,.
The form brings up the mutiple enteries to edit, but when the submit is pushed it refreshes with the original information. i've checked the databse and that remains unchanged.
I'd be greatful of some help.
Thanks

<?php


// Connect to server and select databse.
mysql_connect("localhost", "***", "***")or die("cannot connect");
mysql_select_db("***")or die("cannot select DB");

$sql="SELECT * FROM competition";
$result=mysql_query($sql);

// Count table rows
$count=mysql_num_rows($result);
echo $count."<br/>";
?>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<form name="form1" method="post" action="">

<table width="500" border="0" cellspacing="1" cellpadding="0">


<tr>
<td align="center"><strong>Id</strong></td>
<td align="center"><strong>Date</strong></td>
<td align="center"><strong>Day</strong></td>
<td align="center"><strong>Type</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center"><?php $id[]=$rows['id']; ?><?php echo $rows['id']; ?></td>
<td align="center"><input name="dates[]" type="text"  value="<?php echo $rows['dates']; ?>"></td>
<td align="center"><input name="day[]" type="text"  value="<?php echo $rows['day']; ?>"></td>
<td align="center"><input name="type[]" type="text"  value="<?php echo $rows['type']; ?>"></td>
</tr>
<?php
}
?>
<tr>
<td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>

</form>
</table>
<?php
// Check if button name "Submit" is active, do this
if($Submit){
for($i=0;$i<$count;$i++){
$sql1="UPDATE `competition` SET `dates`='$dates[$i]', `day`='$day[$i]', `type`='$type[$i]' WHERE `id`='$id[$i]'";
$result1=mysql_query($sql1);
}
}

if($result1){
header("location:update_multiple.php");
}
mysql_close();
?>

</html>

All of the code between <?php and ?> is executed on the server and the variables that you are using in the PHP script do not retain their values. Once you submit a form the values are in the corresponding $_POST[] variables so your if ($Submit) is acuually looking at an unitialized variable. You nood to change that statment to:

if (isset($_POST['Submit'] {
//
// Do something
//
}

This also means that you need to retrieve all of the other variables in a similar fashion:

$dates = $_POST['dates'];
$day   = $_POST['day'];
$type  = $_POST['type'];

Also, PHP scripts are processed from the top down. The way you have this coded, you are going to load the table with the existing table data before updating the table. You need to move the if (isset($_POST portion of the code above the the table load. The if (isset($_POST will prevent the update code from running the first time the web page is displayed.

svilla is right.....
If you are submitting form then you must use ($_POST) .
And also to check if it contains any value you must use the function isset($_POST)

To get more idea about isset click here and for $_POST click here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.