使用以下查询:
SELECT title, nid, created FROM node WHERE uid = $account->uid ORDER BY changed DESC
如何打印标题,nid,单独创建(用PHP)?
谢谢! (我确定这很简单,我还不习惯PHP)
答案 0 :(得分:1)
这是一个非常基本的问题,请尝试使用google进行教程。这是关于PHP和mysql的第一个google结果的c / p,它显示了你所追求的技术。
// Retrieve all the data from the "example" table
$result = mysql_query("SELECT * FROM example")
or die(mysql_error());
// store the record of the "example" table into $row
$row = mysql_fetch_array( $result );
// Print out the contents of the entry
echo "Name: ".$row['name'];
echo " Age: ".$row['age'];
答案 1 :(得分:0)
如果您只期望一个结果:
$query = "SELECT title, nid, created FROM node WHERE uid = '".$account->uid."' ORDER BY changed DESC";
$resource = mysql_query($query) or die (mysql_error());
if(mysql_num_rows($resource)>0)
{
$row = mysql_fetch_array($resource);
echo 'Title: '.$row['title'].'<br />';
echo 'ID: '.$row['nid'].'<br />';
}
else
{
echo 'no record found';
}
否则(我现在重读了问题的标题,对不起)
while ($row = mysql_fetch_array($resource))
{
echo 'Title: '.$row['title'].'<br />';
echo 'ID: '.$row['nid'].'<br />';
}