要按日期订购结果,您可以像这样扩展您的查询
SELECT * FROM news ORDER BY `submission_date` DESC //or "ASC" for opposite order使用您的列名称。处理不同的结果
while ($row = mysql_fetch_assoc($result)) { //for each returned row
switch($row['type']){ //your column name for field
case 'release_date':
echo $row['name']." will be released on";
break;
case 'new_video':
echo $row['name']." has a new video";
break;
//other cases
default: //if there should be a process for "anything else"-cases
//code
break;
}
}编辑:
在这一点上“回声”不会让你开心;我想你想用html输出结果;然后你必须在循环开始之前定义一个变量并在循环中填充它。喜欢这个:
$html = ''; //set variable
while ($row = mysql_fetch_assoc($result)) { //for each returned row
switch($row['type']){ //your column name for field
case 'release_date':
$html .= "
".$row['name']." will be released on
";break;
case 'new_video':
$html .= "
".$row['name']." has a new video
";break;
//other cases
default: //if there should be a process for "anything else"-cases
//code
break;
}
}
echo $html;
/*$html is now filled with some paragraphs.
You should echo it inside a complete html-structure
with doctype and inside the body-tag.
The position of the echo inside you script depends on the rest of your code. */
因为您要插入用户定义的内容,请确保输入