1
你好我寫的函數代碼保存在MySQL數據庫功能
我想保存的功能代碼巫包含到MySQL數據庫表HTML
function writeMsg(){
$result = mysql_query('SELECT * FROM `wp_farsc`');
if($result && mysql_num_rows ($result)> 0){
echo '<table border="2px" cellspacing="5px" width="100%">'.PHP_EOL;
echo '<tr bgcolor="yellow"><th>سکه</th><th>قیمت انلاین</th><th>تغییر قیمت</th><th>کمترین</th><th>بیشترین</th><th>زمان بروز رسانی</th></tr>'.PHP_EOL;
while($row = mysql_fetch_assoc($result)){
echo'<tr>';
echo '<td>'.$row ['titile'].'</td>';
echo '<td>'.$row ['liveprice'].'</td>';
echo '<td>'.$row ['changing'].'</td>';
echo '<td>'.$row ['lowest'].'</td>';
echo '<td>'.$row ['topest'].'</td>';
echo '<td>'.$row ['time'].'</td>';
echo'</tr>'.PHP_EOL;
}
}
mysql_close();
}
,然後我convoert功能writeMsg到varible
$oiobz1 = writeMsg(1, 'center', '', 1);
然後保存到數據庫中
@mysql_connect("localhost","root","") or die('connection error');
mysql_select_db('gas') or die('Can not connect to the database');
@ mysql_query("set names utf8");
$title ="today list";
$content =" writemsg()";
$statuse="Publish";
$pingo="open";
$commento="open";
$typee="post";
$auther="1";
$sql = "INSERT INTO `wp_posts`( post_author,post_title,post_content,post_status,post_type,ping_status,comment_status) VALUES('$auther','$title','". $oiobz1."','$statuse','$typee','$pingo','$commento')";
@ mysql_query($sql);
後數據保存到dabase,所有字段從POST_CONTENT .. POST_CONTENT分開存放是空..
http://i.stack.imgur.com/YgGX7.jpg
你做得不對;從不在DB中保存一個函數,只保存數據。 只需在需要時調用即可。我們需要更多關於你想要幫助你的信息。 – Loenix 2015-02-06 08:12:39