Jump to content

[SOLVED] Small easy to fix problem i think.. Im still noob sorry..


mikelmao

Recommended Posts

sort it ascending

 

SELECT * FROM news WHERE news_id=$id ORDER BY id ASC;

 

also in many forums multiposting like that is frowned upon

 

edit: that was just using logic, I have no idea if it actually works or not, if am a complete noob at sql, starting trying it yesterday

 

edit2: can you post your entire php code though as i think I am trying to do the same thing as you, or similar

Link to comment
Share on other sites

include "connect.php";

$news = mysql_query("SELECT * FROM rs");

if(mysql_num_rows($news) > 0)

{

  while($n = mysql_fetch_array($news))

  {

  print "<dt><span class='newsdate'>" . $n['date'] . "</span>" . $n['titel'] . "</dt>";

  print "<dd>

<table width='100%'><tr>

<td style='text-align: justify; vertical-align: top;'>". nl2br($n['news']) ."</td>

<td style='padding-left: 1em; text-align: right; vertical-align: top;'>

</td></tr></table>";

  }

}

else

  {

  echo "ther is no news";

  }

  mysql_close($con);

?>

Link to comment
Share on other sites

Try this

 

 

<?php

include "connect.php";

$news = mysql_query("SELECT * FROM rs ORDER BY id ASC");
if(mysql_num_rows($news) > 0)
{
  while($n = mysql_fetch_array($news))
  {
  print "<dt><span class='newsdate'>" . $n['date'] . "</span>" . $n['titel'] . "</dt>";
  print "<dd>
  <table width='100%'><tr>
  <td style='text-align: justify; vertical-align: top;'>". nl2br($n['news']) ."</td>
  <td style='padding-left: 1em; text-align: right; vertical-align: top;'>
  </td></tr></table>";
  }
}
else
  {
  echo "There is no news at the moment.";
  }
mysql_close($con);
?>

 

Link to comment
Share on other sites

Try this

 

 

<?php

include "connect.php";

$news = mysql_query("SELECT * FROM rs ORDER BY id ASC");
if(mysql_num_rows($news) > 0)
{
  while($n = mysql_fetch_array($news))
  {
  print "<dt><span class='newsdate'>" . $n['date'] . "</span>" . $n['titel'] . "</dt>";
  print "<dd>
  <table width='100%'><tr>
  <td style='text-align: justify; vertical-align: top;'>". nl2br($n['news']) ."</td>
  <td style='padding-left: 1em; text-align: right; vertical-align: top;'>
  </td></tr></table>";
  }
}
else
  {
  echo "There is no news at the moment.";
  }
mysql_close($con);
?>

 

Tryed it but the newest post is still as last

Link to comment
Share on other sites

similar problem

 

what would be the correct way of doing this?

 

$result = mysql_query('SELECT * FROM `madnessred_sites` ORDER BY '$sort' '$order' '); 

 

edit: answere

 

$result = mysql_query("SELECT * FROM `madnessred_sites` ORDER BY '$sort' '$order' "); 

 

Also I found out what wrong with the code we gave lmao, ASC isn't right for ascending.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.