Friday, 15 January 2010

html - Updating MySQL Record with PHP - SQL works, php side does not -



html - Updating MySQL Record with PHP - SQL works, php side does not -

i've been testing sql in phpmyadmin, know sql works fine when phone call through form button doesn't anything. can give me thought of i'm doing wrong.

this php in main form page:

<?php echo "<table border='1'> <tr> <th>firstname</th> <th>lastname</th> <th>age</th> <th>hometown</th> <th>job</th> <th>health</th> <th>damage</th> </tr>"; while($row = mysql_fetch_row($result)) { echo '<tr>'; foreach($row $cell) { echo "\n<td>$cell</td>"; } echo '<td><form method="post" action="attack.php"> <input name="update" type="button" value="update record" /> <input type="hidden" name="'.$row[1].'" /></form></td></tr>'; echo "\n\n"; echo "test"; } ?> <?php require_once('config.php'); $sqltest = $sqltest - 5; $id = floor($_get['id']); if($id > 0) { $sql1="update ajax_demo set health = health - damage"; $result=mysql_query($sql1); mysql_close(); } ?>

obvisouly add together varibles nito sql string testing purposes left such. if can help muchly appricated.

use query

$sql1="update ajax_demo set `health` = `health` - `damage`"; // set actual computed value.

if utilize

`health` = 'health - damage' // set text health - harm not computed value

php html mysql sql

No comments:

Post a Comment