Back again, this time my buttons...work! [SOLVED]
Posted: Mon May 19, 2008 1:19 pm
Okay, so I am making a button so that it adds +1 to a value in a given cell in my database. I do this by calling the ID for the row that my cell is in, posting it, then using it to determine where the proper cell is. Then I increase the number by one, and UPDATE the cell with my new value and return myself to the previous page. The button form from my first page looks like this:
I have everything connecting properly up top and such then when the button is pressed it takes you to:
there are two loops in there that I use for testing, the first is to print out the original data, then increments the specified value and then prints the new number. The second loop prints the new data which should be updated as this point, since my update script is between the two. (when testing I leave out the redirect and exit script so that I can see what prints out to make sure its working)
I have this working perfectly on another database, doing the exact same thing. Can anyone let me know WHY this is not behaving here? If you need any additional information I will be happy to provide, just not sure what all you may need.
Edit: It occured to me that I never actually specified the problem, whoops. Anyway the problem is that when I go through all of this the update isn't updating properly. It updates the number but doesn't update the database.
-Z
Code: Select all
<?php
$data = mysql_query("SELECT * FROM dealers") or die(mysql_error());
while($info = mysql_fetch_array( $data )) : ?>
<td align="center"><?php echo $info['in']?><br>
<form action="dealercounter.php" method ="post">
<input name="in" type="hidden" value="<?php print $info['dealership']?>">
<input type="submit" value="In +1" >
</form>
</td>
<? endwhile; ?>Code: Select all
<?php
$newname = $HTTP_POST_VARS['in'];
@ $db = mysql_pconnect('localhost','****','*******');
mysql_select_db(intranet);
$result = mysql_query("SELECT * FROM dealers
WHERE dealership='$newname'");
while($row = mysql_fetch_array($result))
{
echo $row['dealership'] . " " . $row['in'];
$increment = $row['in'];
$increment++;
echo "<br>".$increment;
}
mysql_query("UPDATE dealers SET in = '$increment'
WHERE dealership = '$newname'");
$result2 = mysql_query("SELECT * FROM dealers
WHERE dealership='$newname'");
while($row = mysql_fetch_array($result2))
{
echo "<br>".$row['dealership'] . " " . $row['in'];
}
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=dealertrade.php">';
exit;
?>I have this working perfectly on another database, doing the exact same thing. Can anyone let me know WHY this is not behaving here? If you need any additional information I will be happy to provide, just not sure what all you may need.
Edit: It occured to me that I never actually specified the problem, whoops. Anyway the problem is that when I go through all of this the update isn't updating properly. It updates the number but doesn't update the database.
-Z