homers Posted October 5, 2009 Report Share Posted October 5, 2009 (edited) <?php mysql_connect("localhost","root",""); mysql_select_db("bba"); $koments = $_POST['koments']; if(isset($_POST['edit'])){ echo "<font color=green>Izlabots!</font>"; mysql_query("UPDATE comments SET koments=$koments WHERE id=".$_GET['id'].""); } ?> un forma: <form action='' method='post'> <input name="koments" type="text" value="<?php echo $kom; ?>"> <input name="edit" type="submit" value="labot"> </form> Edited October 5, 2009 by homers Quote Link to comment Share on other sites More sharing options...
briedis Posted October 5, 2009 Report Share Posted October 5, 2009 mysql_query("UPDATE comments SET koments='$koments' WHERE id='".$_GET['id']."'"); Ieteiktu arī izmantot mysql_real_escape_string() funkciju, nevis pa taisno bāzt post datus kvērijā. (SQL injekcija iespējama) Quote Link to comment Share on other sites More sharing options...
homers Posted October 5, 2009 Author Report Share Posted October 5, 2009 Paldies aizgāja, bet kāds var pateikt/iedot skriptu ka rada kā ir izlabots, bet ja nav tad neko nerada? Quote Link to comment Share on other sites More sharing options...
briedis Posted October 5, 2009 Report Share Posted October 5, 2009 (edited) <?php mysql_connect("localhost","root",""); mysql_select_db("bba"); $koments = mysql_real_escape_string($_POST['koments']); if(isset($_POST['edit'])){ $data = mysql_query("UPDATE comments SET koments='$koments' WHERE id='".$_GET['id']."'"); if(mysql_affected_rows($data)){ echo "Ieraksts tika mainīts"; }else{ echo "Nekas netika labots"; } } ?> Edited October 5, 2009 by briedis Quote Link to comment Share on other sites More sharing options...
homers Posted October 5, 2009 Author Report Share Posted October 5, 2009 (edited) Nē bet lai rada pie komentarā, piemēram rekur man izvelk komentāru <div><a href="?a=lietotajs&id='.$autora_id.'>$r['autors']"</a></div><div>$r['koments']</div> Un tē kur izvelkt komentāru kaut kur malā rada Kā šīs komentārs ir labots tada datumā Edited October 5, 2009 by homers Quote Link to comment Share on other sites More sharing options...
briedis Posted October 5, 2009 Report Share Posted October 5, 2009 Nu tad tev vēl jāpievieno papildus kolonna ar datumu, kad pēdējo reizi labots. Kas tur īsti nav skaidrs? $data = mysql_query("UPDATE comments SET koments='$koments', last_edited = '" . time() . "' WHERE id='".$_GET['id']."'"); Quote Link to comment Share on other sites More sharing options...
Kemito Posted October 5, 2009 Report Share Posted October 5, 2009 google ir pilna ar dažnedažādiem piemēriem par komentāriem! Lielākoties ja spēj izdomāt vienu šādu kveriju + formu zināsi arī pārējo ko tev vaig vismaz šājā gadījumā! http://www.google.lv/#hl=lv&q=php+simple+comment+system&meta=&fp=e43a42b247372469 Domāju ka šeit būtu atbildes! 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.