autly Posted December 1, 2006 Report Share Posted December 1, 2006 <? //connect to mysql //change user and password to your mySQL name and password mysql_connect("localhost","root",""); //select which database you want to edit mysql_select_db("aaa"); //If cmd has not been initialized if(!isset($cmd)) { //display all the news $result = mysql_query("select * from news order by id"); //run the while loop that grabs all the news scripts while($r=mysql_fetch_array($result)) { //grab the title and the ID of the news $title=$r["title"];//take out the title $id=$r["id"];//take out the id //make the title a link echo "<a href='delete.php?cmd=delete&id=$id'>$title - Delete</a>"; echo "<br>"; } } ?> <? if($_GET["cmd"]=="delete") { $sql = "DELETE FROM news WHERE id=$id"; $result = mysql_query($sql); echo "Row deleted!"; } ?> Ta vins jau strada, bet ir maza kluda kautkur paslepusies, neesmu es nekads profins php un mysql lietas, bet nu maacos kaa varu. Kluda ir sekojoshna es ataisu delete.php ar mozila firefox. Un tur errors, bet delete strada. Reku source cods kas nemts no firefox mozila's <a href='delete.php?cmd=delete&id=14'>Patiesība par online atkarību - Delete</a><br><a href='delete.php?cmd=delete&id=15'>ASUS plate ar iebūvētu Skype - Delete</a><br><a href='delete.php?cmd=delete&id=16'>Konkurss — uzlauz mājas lapu un iegūsti «Playstation 3» - Delete</a><br> <br /> <b>Notice</b>: Undefined index: cmd in <b>c:\program files\webserver\www\delete.php</b> on line <b>30</b><br /> Kas var paliidzeet? Link to comment Share on other sites More sharing options...
andrisp Posted December 1, 2006 Report Share Posted December 1, 2006 1) paste.php.lv, nevienam negribas manuāli skaitīt līdz 30. rindai. 2) if(!empty($_GET['cmd']) && $_GET["cmd"]=="delete") Link to comment Share on other sites More sharing options...
autly Posted December 1, 2006 Author Report Share Posted December 1, 2006 Paldies viss straada :* Link to comment Share on other sites More sharing options...
rpr Posted December 1, 2006 Report Share Posted December 1, 2006 vispirms paskaties ko noziimee error notice. iemaacies konfigureet php.ini un tad jau buus ok Link to comment Share on other sites More sharing options...
andrisp Posted December 1, 2006 Report Share Posted December 1, 2006 rpr, tu viņam iesaki izslēgt notices un neņemt tās galvā ? Link to comment Share on other sites More sharing options...
Recommended Posts