Jump to content
php.lv forumi

hipnoz

Reģistrētie lietotāji
  • Posts

    2
  • Joined

  • Last visited

hipnoz's Achievements

Newbie

Newbie (1/14)

  1. 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
  2. Kad notiek UPDATE vins visu updeito, bet nevis tikai tos kur es ierakstu skaitli. Gribetu lai tiek update un insert tikai tie kur value ir kads skaitlis. Kads sim kodam bus skripts kas insert jauna table update datus? Ka panakt ka update un insert tikai kur value ir kads skaitlis? <?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 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
×
×
  • Create New...