GIDForums  

Go Back   GIDForums > Webmaster Forums > Web Design Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 17-Apr-2003, 08:02
jrobbio's Avatar
jrobbio jrobbio is offline
Regular Member
 
Join Date: Jan 2003
Location: Loughborough, England
Posts: 840
jrobbio will become famous soon enough

PHP/mySQL backend configuration help needed


Below is my php backend to my site, I've managed to get it to work and its running smoothly, but I have an issue I was hoping you lot could help me sort out.

I'll highlight the first problem (the number) in bold

- <item>
<title>Mensa Workout</title>
<link>http://www.topfunwebsites.com/mambo/...window.php?id=<b>83</b></link>
<description>So you think you are clever do you? Well try the Mensa Workout (http://www.mensa.org/workout.html) ...</description>

The problem here is that this is my newest post, but it is appearing at the bottom because it has the largest ID number. Instead, I want it to appear at the top. What do I need to do to this? Thanks very much.

PHP Code:

<?php

include ("configuration.php");
$outputfile="mysite.xml";
$descr="$sitename";

$fo=fopen($outputfile,"w+");
fputs ( $fo, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" );
fputs ( $fo, "<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\"
 \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n\n" );

fputs ( $fo, "<rss version=\"0.91\">\n");
fputs ( $fo, "<channel>\n" );
fputs ( $fo, "<title>$sitename</title>\n ");
fputs ( $fo, "<link>$live_site</link>\n");
fputs ( $fo, "<description>$descr</description>\n");
fputs ( $fo, "<language>en-us</language>\n");

mysql_connect($host, $user, $password);
$query = "SELECT sid, title, introtext FROM ".$dbprefix."stories WHERE published='1'";
$result = mysql_db_query($db,$query) or die("Did not execute query");;
$num = mysql_num_rows($result);
$i=1;
$j=0;
while ($num>=$i) {
    $row = mysql_fetch_array($result);
    $title = $row["title"];
    $introtext = $row["introtext"];
    $id = $row["sid"];
    fputs ($fo,"<item>\n");
    fputs ($fo,"<title>$title</title>\n");
    fputs ($fo,"<link>$live_site/popups/newswindow.php?id=".$row["sid"]."</link>\n");
    $words = $introtext;
                $words = preg_replace("'<script[^>]*>.*?</script>'si","",$words);
                $words = preg_replace('/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is','\2 (\1)', $words);
                $words = preg_replace('/<!--.+?-->/','',$words);
                $words = preg_replace('/{.+?}/','',$words);
                $words = strip_tags($words);
                
    fputs ($fo,"<description>".substr($words,0,100)."...</description>\n");
    fputs ($fo,"</item>\n");
    $i++;
}

fputs ( $fo, "</channel>\n");
fputs ( $fo, "</rss>\n");
fclose( $fo );

print "<SCRIPT>document.location.href='mysite.xml'</SCRIPT>\n";
?>

  #2  
Old 17-Apr-2003, 09:59
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

ORDER BY


Try changing
PHP Code:

<?php
$query = "SELECT sid, title, introtext FROM ".$dbprefix."stories WHERE published='1'";
?>


to
PHP Code:

<?php
$query = 'SELECT sid, title, introtext FROM '
         .$dbprefix.'stories '
         .'WHERE published=1 '
         .'ORDER BY sid DESC';
?>

  #3  
Old 17-Apr-2003, 10:07
jrobbio's Avatar
jrobbio jrobbio is offline
Regular Member
 
Join Date: Jan 2003
Location: Loughborough, England
Posts: 840
jrobbio will become famous soon enough
You my friend are an absolute star! Thank you for the quick reply and sorting it out for me I owe you big time. I needed it for my klipfolio feed at Klipfolio since it was looking really wrong the way it was. This makes it so much more simpler.

Rob
 

Recent GIDBlogPrepping for deployment by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Free 1st month / Free setup / No credit card needed...Plans start at 4.95 LarryIsaac Web Hosting Advertisements & Offers 0 11-Oct-2003 14:03

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 22:54.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.