Jump to content
php.lv forumi

Recommended Posts

Posted (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 by airbus
Posted

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.

Posted

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 (~;

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...