您的位置:首页 > 数据库

新浪SAE链接数据库

2016-10-01 23:39 232 查看
实例代码:

db=mysqlconnect(“qvnxelmkchho.rds.sae.sina.com.cn”.′:′.′10338′,′root′,′admin888′);mysqlselectdb(‘demo′);mysqlquery(‘SETNAMESUTF8′);sql=”SELECT title,description,picUrl,url FROM img ORDER BY ids LIMIT 0,10”;

res=mysqlquery(sql)

//循环取出数据

itemCount=0;//统计有几条数据while(row=mysql_fetch_assoc($res)){

$contentStr.= sprintf($newsTplItem,$row['title'],$row['description'],$row['picUrl'],$row['url']);
++$itemCount;//统计有几条数据
}
$newsTplHeader=sprintf($newsTplHeader,$fromUsername,$toUsername,$time,$itemCount);
$resultStr=$newsTplHeader.$contentStr.$newsTplFooter;

echo $resultStr;


核心代码:分离模板

$newsTplHeader=”
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: