Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Php won't order my database pulls.
Old 12-10-2005, 01:19 AM Php won't order my database pulls.
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Howdy yall!

For some reason, mysql won't order my News tables on my website.
PHP Code:
$sql_text "SELECT * FROM ".$this->TABLES['news']." WHERE id = '".$id."' ORDER BY id DESC"
I'm assuming that the ORDER BY will order the sellected information from the database pull by highest id to lowest id.

For some reason it isnt wanting to

Also, I'm having trouble with Line breaks in my news forms. In the database it is showing the correct line breaks, but when displayed on website, its all one big line. http://www.operanonverba.com/index1.php?page=news

If you need anymore code please let me know. I don't know what im doing wrong with the order by.

Thankyou,
Greg
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-10-2005, 03:32 AM
Ultra Talker

Posts: 251
Location: Belgium, Antwerp, Zoersel
Trades: 0
PHP Code:
...WHERE id '".$id."' ORDER BY id... 
You're using the id to select the item, so it's the same for all selected items, so you can't really order them by that.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Orodreth is offline
Reply With Quote
View Public Profile Visit Orodreth's homepage!
 
Old 12-10-2005, 05:07 AM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
On the second issue.

You need to replace line breaks with <br>
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-10-2005, 04:11 PM
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Quote:
Originally Posted by Orodreth
PHP Code:
...WHERE id '".$id."' ORDER BY id... 
You're using the id to select the item, so it's the same for all selected items, so you can't really order them by that.
Thanks Orodreth, makes perfect sense. Dunno how i missed it

'chrishirst'

so,
PHP Code:
<?php

function nl2br_skip_html($string)
{
   
// remove any carriage returns (mysql)
   
$string str_replace("\r"''$string);

   
// replace any newlines that aren't preceded by a > with a <br />
   
$string preg_replace('/(?<!>)\n/'"<br />\n"$string);

   return 
$string;
}

?>
I feed $string (or the stored typing) into the function, it formats the text and then spits it back?

Greg
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Php won't order my database pulls.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13615 seconds with 12 queries