SunQuest
 
           PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old July 31st, 2003, 04:21 AM
velocityX velocityX is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 72 velocityX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 36 sec
Reputation Power: 6
Send a message via AIM to velocityX
help with php list data script

how do you make it list from last to first?
PHP Code:
 mysql_connect(localhost,$username,$password);
@
mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM velocity_news LIMIT 3";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

echo 
"<b><center>news</center></b><br><br>";

$i=0;
while (
$i $num) {

$news=mysql_result($result,$i,"news");
$date=mysql_result($result,$i,"date");
$topic=mysql_result($result,$i,"topic");

echo 
"News for $date<br>";
echo 
"<b>$topic</b><br>";
echo 
"$news<br><br><br><br>";

++
$i;


Reply With Quote
  #2  
Old July 31st, 2003, 07:03 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
PHP Code:
 SELECT FROM velocity_news ORDER BY date DESC LIMIT 3 

Reply With Quote
  #3  
Old July 31st, 2003, 03:51 PM
velocityX velocityX is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 72 velocityX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 36 sec
Reputation Power: 6
Send a message via AIM to velocityX
THX, now does anybody knows how to do a check so it wont add another entry to the table with the same date?

Reply With Quote
  #4  
Old August 1st, 2003, 07:16 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
You'll just have to do server-side validation prior to inserting. Select count(*) from the table where date is the submitted date. If count > 0, return an error and don't insert. Else insert. Theoretically, I suppose you could make the date field a unique field (not sure date fields even support that), but doing so strikes me as an odd and probably a bad idea.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > help with php list data script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway