Hi, Newbie in Php..please help how do i echo this <?php echo $dateadded; ?> PHP: into this <item> <title>'. $rss_row['title'] .'</title> <description>'. $rss_row['description'] .'</description> <link>'. fileurl($rss_row['fileid'], $rss_row['title']) .'</link> </item>'; PHP: Thanks advance
If date added isn't in your database you can't echo or show anything. what are you asking exactly? You can't make a function or variable without defining what it does or is. You can store time in php to your database as time() then need a function to make it a "pretty time".
Can't say for sure, but its going to be similar to what you have, something like <date>'. $rss_row['date'] .'</date> Open up your phpmyadmin and see what label the dateadded row is called.
If the variable $dateadded already contains the date. Then just add it where you want it to be. Example below. Note: The position where I added it is likely not a good place. It is just to show how it is done. <item> '.$dateadded.' <title>'. $rss_row['title'] .'</title> <description>'. $rss_row['description'] .'</description> <link>'. fileurl($rss_row['fileid'], $rss_row['title']) .'</link> </item>'; PHP: This is the key part. '.$dateadded.' PHP:
What vodafone said sounds right to me too -- you say it's already in the database as part of the item, so it would be returned as a value in $rss_row I'm going to assume you are using RSS 2.0 and not Atom, since you're saying 'description' as a XML tag. In terms of keeping that valid for RSS 2.0 <item> <title>' . $rss_row['title'] . '</title> <datepub>' . $rss_row['date'] . '</datepub> <description>' . $rss_row['description'] . '</description> <link>' . fileurl($rss_row['fileid'], $rss_row['title']) .'</link> </item>'; Code (markup): Is where you'd plug in 'date' -- though again you need to know what that is called in the database those rows are being pulled from. Also if that's an echo instead of a string addition, swap out all those periods for comma's... just saying. However, if you actually HAVE a variable called 'dateadded' for whatever oddball reason, replace $rss_row['date'] with $dateadded.
..and just to add, make sure your query actually calls the date for this specific result, as in, at the moment your query might only request title, description and link etc...
<item> '.$dateadded.' <title>'. $rss_row['title'] .'</title> <description>'. $rss_row['description'] .'</description> <link>'. fileurl($rss_row['fileid'], $rss_row['title']) .'</link> </item>'; PHP: This is work but its very weird...i can see the month, date, years in the (view source code) but its blank on the page...anyone know why? Thanks
Pay attention to mine -- You're building RSS 2.0 so EVERYTHING has to go in it's own tag. Dumping it in blindly like that is invalid XML and invalid RSS 2! You must use one of the official RSS2 tags -- datepub being the closest there is to dateadded. Date it was published... though you may also want <lastBuildDate> <datepub>'.$dateadded.'</datepub> Take a look at the specification and pay attention to the required and optional params. http://feed2.w3.org/docs/rss2.html#requiredChannelElements http://feed2.w3.org/docs/rss2.html#optionalChannelElements You may also want to htmlspecialchars all your fields in the output.
May be you need to format date before output http://www.php.net/manual/en/function.date.php so the code for RSS will be like <?php echo date('D, d M Y h:i:s O', $dateadded); ?>