OK,
Well I've got this script and I'd like to implement this function into it where a function retrieves a specified amount of data from a specific mysql database, rearranges a part of it, and outputs the result to another specified varible. this is what i've got so far (please ignore the long-winded variables, they are just for explanations):
[PHP]function RearrangeDate ($input-data/time, $the-way-it-should-be-arranged-e.g.-D/m/y-(not implemented)) {
$date = substr($timedat e, 0, 10);
$year = substr($date, 0, 4);
$month = substr($date, 5, 2);
$day = substr($date, 8, 2);
$newdate = $day . "/" . $month . "/" . $year;
output $newdate
}
function GetWP ($amount-of-rows-to-output) {
$sql =
"SELECT `post_date`, `post_title`
FROM `wp_posts`
WHERE (post_type = 'post' AND post_status = 'publish')
ORDER BY `wp_posts`.`pos t_date` DESC
LIMIT 0,$amount-of-rows-to-output";
$query = mysql_query($sq l);
$array = mysql_fetch_row ($query);
$timedate = $array[0];
RearrangeDate($ timedate, d/m/y);
$text = $newdate . " - " . $array[1];
output $test
}[/PHP]
What it does is retrieves the mysql row and renames the variables (which once it is integrated into a function it wouldn't have to do). Then it passes the date/time variable to another function which strips the time and rearranges the date from American date to a specified format. Then the RearrangeDate function outputs the new arrangement and the GetWP function outputs the final variable arranged in a readable way.
But this script only retrieves the first row and doesn't output the result properly. Can anyone fix this horrific script (as I only have basic PHP knowledge) and point out any areas where it would need a cleanup?
Well I've got this script and I'd like to implement this function into it where a function retrieves a specified amount of data from a specific mysql database, rearranges a part of it, and outputs the result to another specified varible. this is what i've got so far (please ignore the long-winded variables, they are just for explanations):
[PHP]function RearrangeDate ($input-data/time, $the-way-it-should-be-arranged-e.g.-D/m/y-(not implemented)) {
$date = substr($timedat e, 0, 10);
$year = substr($date, 0, 4);
$month = substr($date, 5, 2);
$day = substr($date, 8, 2);
$newdate = $day . "/" . $month . "/" . $year;
output $newdate
}
function GetWP ($amount-of-rows-to-output) {
$sql =
"SELECT `post_date`, `post_title`
FROM `wp_posts`
WHERE (post_type = 'post' AND post_status = 'publish')
ORDER BY `wp_posts`.`pos t_date` DESC
LIMIT 0,$amount-of-rows-to-output";
$query = mysql_query($sq l);
$array = mysql_fetch_row ($query);
$timedate = $array[0];
RearrangeDate($ timedate, d/m/y);
$text = $newdate . " - " . $array[1];
output $test
}[/PHP]
What it does is retrieves the mysql row and renames the variables (which once it is integrated into a function it wouldn't have to do). Then it passes the date/time variable to another function which strips the time and rearranges the date from American date to a specified format. Then the RearrangeDate function outputs the new arrangement and the GetWP function outputs the final variable arranged in a readable way.
But this script only retrieves the first row and doesn't output the result properly. Can anyone fix this horrific script (as I only have basic PHP knowledge) and point out any areas where it would need a cleanup?
Comment