0

我正在尝试制作生日功能,该功能假设从数据库中提取信息并给出当天生日的人的姓名、姓氏等。我走得好吗?我做了这样的事情:

<?php

function birthday($year){


extract(shortcode_year(array('how_many_days'=>'1'),$year));
require('./wp-load.php');

global $wpdb;

for($i=0; $i<=$how_many_days; $i++)
{

$day = $i*24*60*60;

for($j=18; $j<=75; $j++){

$past_day=mktime(0,0,0, date(n,time()), date(j,time()), date(Y, time()) - $j) + $day;

$results=$wpdb>get_results("SELECT first_name, last_name, date_birthday,private_id, responsible FROM wp_participants_database WHERE date_birthday=$past_day");

foreach($results as $result): $brojac=$brojac+1;

echo '<TR><TD align=right>', $j, 'ans:', $result->first_name, '</TD><TD><B>',
$result->last_name, '<B></TD><TD>', $result->private_id, date(Y,$result->date_birthday),"/", 
date(m, $result->date_birthday), "/", date(d, $result->date_birthday),'</TD></TR>=>', $result->responsible,'<br/>';
endforeach;    

   }
  }
 }

add_shortcode('birthday', 'birthday');

?>
4

1 回答 1

0

我注意到你->在这一行不见了

$results=$wpdb>get_results("SELECT first_name, last_name, date_birthday,private_id, responsible FROM wp_participants_database WHERE date_birthday=$past_day");

应该是这样的

$results=$wpdb->get_results("SELECT first_name, last_name, date_birthday,private_id, responsible FROM wp_participants_database WHERE date_birthday=$past_day");
于 2013-08-07T09:00:36.043 回答