Home >Backend Development >PHP Tutorial > 新手提个问:如何把php的变量赋值到html里

新手提个问:如何把php的变量赋值到html里

WBOY
WBOYOriginal
2016-06-13 12:54:39946browse

新手提个问:怎么把php的变量赋值到html里
我绝对是菜鸟,0起点,来帮帮我吧,自己用的。

<div align="left"><br />
  <h1 align="center"> </h1><br />
  <h1 align="center"><strong>这里放个变量$data</strong></h1><br />
  <p align="center"> </p><br />
</div><br />
<?php<br />
...这里连接数据库<br />
$data=xxx<br />
?>


怎么把后面数据库的结果给他赋过去。


------解决方案--------------------
<br />
<?php<br />
...这里连接数据库<br />
$data=xxx<br />
?><br />
<div align="left"><br />
  <h1 align="center"> </h1><br />
  <h1 align="center"><strong><?php var_dump($data)?></strong></h1><br />
  <p align="center"> </p><br />
</div><br />

还是用个smarty什么的吧 程序和模版分开写好一点
------解决方案--------------------
<br />
<?php<br />
...这里连接数据库<br />
$result = mysql_query($sql);<br />
?><br />
<div align="left"><br />
  <h1 align="center"> </h1><br />
<?php<br />
   while($data = mysql_fetch_assoc($res)){<br />
?><br />
  <h1 align="center"><strong>这里放个变量<?php echo $data['xxx']?></strong></h1><br />
<?php<br />
}<br />
?><br />
  <p align="center"> </p><br />
</div><br />
<br />

大概格式是这样的
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn