airbus Posted August 3, 2009 Report Share Posted August 3, 2009 (edited) Kā šajā selektošanas skriptā uzlikt lai viņš jaunākos liek aukšā, bet vēcakos zemē. <?php $con = mysql_connect("localhost","root","assa"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("eh", $con); $result = mysql_query("SELECT * FROM Chat"); while($row = mysql_fetch_array($result)) { echo "<div style='border: 1px solid rgb(221, 221, 221); -moz-border-radius-bottomleft: 3px; -moz-border-radius-bottomright: 3px;'> <div style='margin: 1px; padding: 5px; background: rgb(238, 238, 238) none repeat scroll 0pt 0pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;'> <div><b>"; echo $row['niks']; echo "</b> - "; echo $row['laiks']; echo "</div></div>"; echo "<div style='border-top: 1px solid rgb(221, 221, 221); padding: 3px; margin-top: 1px;'> <p>"; echo $row['texts']; echo "</p></div></div><br>"; } mysql_close($con); ?> Edited August 3, 2009 by airbus Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted August 3, 2009 Report Share Posted August 3, 2009 SQL pieprasījumu valodā ir iespēja norādīt pēc kuras kolonnas un kādā secībā kārtot. Tev jāpieliek savam "SELECT * FROM Chat" attiecīgā "ORDER BY kolonna" konstrukcija. Quote Link to comment Share on other sites More sharing options...
airbus Posted August 3, 2009 Author Report Share Posted August 3, 2009 Kā uzlikt kad uzspiež uz pogu pievienot ieraksta struktūrā "id" un tad varbūt pēc id kārtot? Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted August 3, 2009 Report Share Posted August 3, 2009 Pakārt nedrīkst apžēlot! Kur komatu liksim? ;) Quote Link to comment Share on other sites More sharing options...
airbus Posted August 3, 2009 Author Report Share Posted August 3, 2009 Uzliku kā karto ar ID, viss aizgaja, bet viņš jaunākos met uz leju nevis uz aukšu Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted August 3, 2009 Report Share Posted August 3, 2009 Tāpēc, ka, ja netiek norādīts, kārtošana notiek augošā secībā (ascending) nevis dilstošā secībā (descending). Pārlasi attiecīgo dokumentācijas (piemēram, MySQL) nodaļu un sapratīsi, kas par vainu (~; Quote Link to comment Share on other sites More sharing options...
waplet Posted August 3, 2009 Report Share Posted August 3, 2009 ASC vai DESC 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.