Jump to content


Photo

SQL Pulling in order, how out of order? :P


  • Please log in to reply
5 replies to this topic

#1 AbydosGater

AbydosGater
  • Members
  • PipPipPip
  • Advanced Member
  • 435 posts
  • LocationAlways at computer!

Posted 07 October 2006 - 04:44 PM

Hi, Sorry for the topic name!, bit confusing... But
Heres my script...

	$query = "SELECT * FROM ben_news ORDER BY id";
	$result = mysql_query($query);
	while($news = mysql_fetch_array($result)) {
$member_id = $news['member_id'];
$author = "SELECT username FROM ben_users WHERE member_id='$member_id'";
	$authorresult = mysql_query($author);
	$authorinfo = mysql_fetch_array( $authorresult );
echo "<table width='455' border='0' cellspacing='0' cellpadding='0' background='image/longmenu.gif' height='34'>
        <tr> 
          <td><FONT FACE='Tahoma'><b>" . $news['title'] . "</b></FONT></td>
        </tr>
      </table> ";
echo "<p>";
echo $news['content'];
echo "</p>";
echo "<p>";	
 echo "<hr><br>"; 
echo "Author: &nbsp; " . $authorinfo['username'] . "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; " . "Date/Time:&nbsp; " . $news['timedate'];
echo "</p>";
};

};



Right no need to read all of that, but the Important bit is $query = "SELECT * FROM ben_news ORDER BY id";

The id field is an Auto Int.. And it all works fine! but i was wondering how do i get it to order backwards? start with the highest number, 5,4,3,2,1... and so on???

Thanks
Abydos
www.abydosgaters.com

Current Project: Blog Application.. Undecided name.. Status: Coming along great.

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 07 October 2006 - 04:45 PM

DESC

or

ASC
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 AbydosGater

AbydosGater
  • Members
  • PipPipPip
  • Advanced Member
  • 435 posts
  • LocationAlways at computer!

Posted 07 October 2006 - 04:46 PM

Ok, Thanks, but where does that go?
www.abydosgaters.com

Current Project: Blog Application.. Undecided name.. Status: Coming along great.

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 07 October 2006 - 04:50 PM

$query = "SELECT * FROM ben_news ORDER BY id ASC";

or

$query = "SELECT * FROM ben_news ORDER BY id DESC";


This link is for you ok.

http://www.1keydata....sql-syntax.html
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 AbydosGater

AbydosGater
  • Members
  • PipPipPip
  • Advanced Member
  • 435 posts
  • LocationAlways at computer!

Posted 07 October 2006 - 04:51 PM

Have It, Thanks very much, fast reply!
www.abydosgaters.com

Current Project: Blog Application.. Undecided name.. Status: Coming along great.

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 07 October 2006 - 04:53 PM

good luck but use the link i provided for mysql as it the best ever mysql website for learning i have ever seen.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users