gpt4 book ai didi

php - mysql数据库中的保存函数

转载 作者:行者123 更新时间:2023-11-29 00:04:03 25 4
gpt4 key购买 nike

<分区>

你好我写函数代码

我想将包含表格html的函数代码保存到mysql数据库中

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();
}

然后我将函数 writeMsg 转换为变量

     $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);

将数据保存到数据库后,所有字段都存储在 post_content 之外.. post_content 为 null ..

http://i.stack.imgur.com/YgGX7.jpg

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com