hipnoz Posted February 7, 2011 Report Share Posted February 7, 2011 Ka panakt ka test_update un test_insert tiek ievietoti tikai tie dati kur value ir bijis kads skaitlis? Ka lai paarnes updeitotos datus no test_update uz test_insert - bridi kad nospiez submit. <?php include ("connection/connect_db.php"); echo "test_update TABLE data:</br>"; ////::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: $sql="SELECT * FROM test_update ORDER BY id ASC;"; $result=mysql_query($sql); // Count table rows $count=mysql_num_rows($result); ////::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ?> <table width="500" border="0" cellspacing="1" cellpadding="0"> <form name="form1" method="post" action=""> <tr> <td><strong>Id</strong></td> <td><strong>Vards</strong></td> <td><strong>Uzvards</strong></td> <td><strong>Skaitlis</strong></td> <td><strong>Atņemt</strong></td> </tr> <tr> <?php while ($row = mysql_fetch_array($result)){ ?> <tr> <td><?php echo $row['id']; ?></td> <td><?php echo $row['vards']; ?></td> <td><?php echo $row['uzvards']; ?></td> <td><?php echo $row['skaitlis']; ?></td> <td><input type="text" name="foo[<?php echo $row['id']; ?>]" value='' /></td> <tr> <? } ?> <tr> <td colspan="4" align="center"> <input type="submit" name="Submit" value="Submit"> </td> </tr> </form> </table> <?php if (isset ($_POST['Submit'])) { foreach($_POST['foo'] as $key=>$v){ $sql1="UPDATE test_update SET skaitlis=(skaitlis-$v) WHERE id='$key'" or die(mysql_error()); $result1=mysql_query($sql1); } echo "update complete"; header ("Location: update_insert.php"); } ?> <?php Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted February 7, 2011 Report Share Posted February 7, 2011 (edited) Tev jau nepietiek ar vienu topiku? (http://php.lv/f/topi...509#entry142509) Skaties te: http://www.tutorials...here-clause.htm P.S. un kodam ir jaaizmanto bloks. Edited February 7, 2011 by rATRIJS Quote Link to comment Share on other sites More sharing options...
Kemito Posted February 7, 2011 Report Share Posted February 7, 2011 Es pat neskatos, ātri atbildu ar to, ka OMG, tos tagus izdomā priekš kam? Lai būtu papriecāties par ko? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.