Eob Posted May 3, 2010 Report Share Posted May 3, 2010 Tātad, ar php kodu (pirmais koda klucis) tiek no datubāzes dinamiski vilkta ārā informācija. Turpat blakus dinamiski tiek izveidota Delete poga. <?php include 'library/config.php'; include 'library/opendb.php'; $query = "SELECT Pardevejs_ID, Pardevejs_vards, Pardevejs_uzvards, Pardevejs_pers_kods, Pardevejs_adrese, Pardevejs_tel_nr FROM pardevejs ORDER BY Pardevejs_ID DESC"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $id = $row['Pardevejs_ID']; $vards = $row['Pardevejs_vards']; $uzvards = $row['Pardevejs_uzvards']; $pkods = $row['Pardevejs_pers_kods']; $adrese = $row['Pardevejs_adrese']; $telnr = $row['Pardevejs_tel_nr']; echo "$id $vards $uzvards $pkods $adrese $telnr "; echo "<input name='delete' type='submit' value='Dzēst'>"; echo "<br>"; } include 'library/closedb.php'; ?> Šis ir kods, ar kuru mēģinu atdzīvināt šo Delete pogu: <?php if(isset($_POST['delete'])) { include 'library/config.php'; include 'library/opendb.php'; $id = $_POST['Pardevejs_ID']; $query2 = " DELETE FROM pardevejs WHERE Pardevejs_ID = $id"; mysql_query($query2) or die('MySQL operācija neizdevās. Pārdevēja dati nav izdzēsti.'); include 'library/closedb.php'; echo "<br>Pārdevējs $vards $uzvards vaiksmīgi izdzēsts no saraksta.<br>"; } ?> Problēma tāda, ka nezinu, kas īsti būtu jāliek $id = $_POST['Pardevejs_ID']; $query2 = " DELETE FROM pardevejs WHERE Pardevejs_ID = $id"; vietā, lai Delete poga izdzēstu tajā pat rindiņā esošo informāciju. Jebkāda veida palīdzība būtu ļoti noderīga. Quote Link to comment Share on other sites More sharing options...
m8t Posted May 3, 2010 Report Share Posted May 3, 2010 Kā izveidot maizīti: http://www.wikihow.com/Make-a-Sandwich while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $id = $row['Pardevejs_ID']; $vards = $row['Pardevejs_vards']; $uzvards = $row['Pardevejs_uzvards']; $pkods = $row['Pardevejs_pers_kods']; $adrese = $row['Pardevejs_adrese']; $telnr = $row['Pardevejs_tel_nr']; echo "$id $vards $uzvards $pkods $adrese $telnr "; echo '<form method="post" action="">'; echo '<input type="hidden" name="Pardevejs_ID" value="'.$id.'>"'; echo "<input name='delete' type='submit' value='Dzēst'>"; echo '</form>'; echo "<br>"; } 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.