What I need to insert is by descending record.
my code:
mysql_query("INSERT INTO entertainment VALUES ('','$result','$date')");
result:
id result date
1 a 26/9/2011
2 b 25/9/2011
3 c 24/9/2011
What I want is:
id result date
1 c 24/9/2011
2 b 25/9/2011
3 a 26/9/2011
Isn't possible do it ?
here is my full code, what i doing now i rss grabbing,once i grab all the result i will insert the result to my database:
$content = file_get_contents($feed_url);
$xml = new SimpleXmlElement($content);
foreach($xml->channel->item as $entry){
$title = mysql_real_escape_string(strip_tags($entry->title));
$description = mysql_real_escape_string(strip_tags($entry->description));
mysql_query("INSERT INTO entertainment VALUES ('','$entry->pubDate','$title','$description')");
}
No.
This is a really bad idea. The (autoincrement) ID column should not be significant for your data - so you really shouldn't care about its value.
Furthermore, how would MySQL know where to start from? If you insert three, it should start from 3 and count to 1, but what if you insert more later?
Instead of changing the order while inserting, you should probably change the query that reads the data later. Have that query return the data really the way you want it.
SELECT *
FROM entertainment
ORDER BY result DESC
INSERT INTO orders (id result date) select id result date from tablename order by id desc
Yes, insert the data in any way, and use SELECT * FROM entertainment ORDER BY date Desc
at the time of retrieval.
精彩评论