student Posted October 28, 2010 Report Share Posted October 28, 2010 (edited) Kāds zina kāds sql order by kods ir jāliek pie query,lai jaunākais ieraksts izvadās augšpusē. <html> <head><title>čats</title></head> <body> <h1>Čats</h1> Tavs teksts : <br> <form action="cats.php" method="post"> <textarea rows="5" COLS="50" NAME="teksts"> </textarea><br> <input type="submit" value="Ievietot"> </form> </body> </html> <?php if(isset($_POST['teksts'])&& $_POST['teksts']!==""){ $teksts=$_POST['teksts']; mysql_connect("localhost","root",""); @mysql_select_db("cats"); $query = "INSERT INTO izvade VALUES (NULL, '$teksts')"; mysql_query($query); } else{ $_POST['teksts']=""; } mysql_connect("localhost","root",""); @mysql_select_db("cats"); $query = "select * from izvade ORDER BY id"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { echo $row['teksts'],"<br>"; } ?> Edited October 28, 2010 by student Quote Link to comment Share on other sites More sharing options...
Rincewind Posted October 28, 2010 Report Share Posted October 28, 2010 ORDER BY id DESC Quote Link to comment Share on other sites More sharing options...
student Posted October 28, 2010 Author Report Share Posted October 28, 2010 un ar to pilnīgi pietiks? Quote Link to comment Share on other sites More sharing options...
Rincewind Posted October 28, 2010 Report Share Posted October 28, 2010 un ar to pilnīgi pietiks? Ja query beigās pielek "ORDER BY id" tad kārtošanas secība būs augoša (1,2,3,...), ja "ORDER BY id DESC" tad dilstoša (10,9,8,...) Quote Link to comment Share on other sites More sharing options...
student Posted October 28, 2010 Author Report Share Posted October 28, 2010 ko īsti nozīmē pie id ieliktais DESK? Quote Link to comment Share on other sites More sharing options...
waplet Posted October 28, 2010 Report Share Posted October 28, 2010 descending.. http://translate.google.lv/#en|lv|descending Quote Link to comment Share on other sites More sharing options...
student Posted October 28, 2010 Author Report Share Posted October 28, 2010 Viss skaidrs!Paldies! Quote Link to comment Share on other sites More sharing options...
Roberts.R Posted October 29, 2010 Report Share Posted October 29, 2010 un ar to pilnīgi pietiks? Nu ja nepietiek ar ID kārtošanu, tad var kārtot arī pēc ievietojuma datuma (jāiekļauj laiks/datums iekš datubāzes) 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.