数据库里面 picture 是varchar类型 id.1的值是 c:\mypic\yyh.jpgecho "<td width='10%'><img src=$title[picture] alt=\"images\"/></td>";这一段不会写 :全部代码如下 :<?php
$titlesql="select id,name,born,gender,identity_card,picture from myfamily;";
?><table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<th width="13%">id</th>
<th width="10%">name</th>
<th width="7%">born</th>
<th width="6%">gender</th>
<th width="8%">identity_card</th>
<th width="8%">picture</th>
</tr>
<?php
while($title=mysql_fetch_array($titleresult)){
echo "<tr> ";
echo "<td width='13%' align=center>$title[id]</td>";
echo "<td width='10%' align=center>$title[name]</td>";
echo "<td width='7%'>$title[born]</td>";
echo "<td width='6%'>$title[gender]</td>";
echo "<td width='8%'>$title[identity_card]</td>";
echo "<td width='10%'><img src=$title[picture] alt=\"images\"/></td>";
echo "</tr>";
}
echo "</table>";
?>
$titlesql="select id,name,born,gender,identity_card,picture from myfamily;";
?><table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<th width="13%">id</th>
<th width="10%">name</th>
<th width="7%">born</th>
<th width="6%">gender</th>
<th width="8%">identity_card</th>
<th width="8%">picture</th>
</tr>
<?php
while($title=mysql_fetch_array($titleresult)){
echo "<tr> ";
echo "<td width='13%' align=center>$title[id]</td>";
echo "<td width='10%' align=center>$title[name]</td>";
echo "<td width='7%'>$title[born]</td>";
echo "<td width='6%'>$title[gender]</td>";
echo "<td width='8%'>$title[identity_card]</td>";
echo "<td width='10%'><img src=$title[picture] alt=\"images\"/></td>";
echo "</tr>";
}
echo "</table>";
?>
解决方案 »
- [在线等]ubuntu 下XAMPP php.ini 开启mongodb 扩展 php文件总是解析失败!!!
- 【性能咨询】图片等资源前加完整IP是否影响性能?
- 关于php debug pack 问题
- PHP+MYSQL查询结果集出错
- xml小问题求救!
- brandhb.com 品牌回报网招聘php工程师
- 圣诞散分
- PHP中数据库操作的过程中,有一些◎符号,请问是什么意思?
- 同一个页面上有个option控件可以选择城市和一个text控件用来显示区号,在option里选择城市,text里会出现相应的区号,这个怎么写啊??
- 请问php中session的超时时间问题
- PHP调用快递API接口报错了
- PHP调用快递API接口报错了
http://www.w3school.com.cn/tags/att_img_alt.asp
现在的$titlesql的值仅仅等于"select id,name,born,gender,identity_card,picture from myfamily;"这一堆字符串.
如果你想执行,必须要在下面加上这一句
mysql_query($titlesql);
这样SQL语句才会被执行.然后就是筛选数据库字段了.
大概如下吧:
$titlesql="select id,name,born,gender,identity_card,picture from myfamily;"
$sql=mysql_query($titlesql);
$row=mysql_fetch_accos($sql);
//执行SQL语句;
echo $row['title'];
//输出字段;
然后在下面的表格中打<?php echo $row['字段名'] ?>就能输出字段对应的文本了.
现在你是想输出图片.那就<img src="<?php echo $row['picture'] ?>" >这样的就能输出图片了.
apache 的话,修改 httpd.conf 在最后加入
ALIAS /mypic "c:/mypic"2、将 echo "<td width='10%'><img src=$title[picture] alt=\"images\"/></td>"; 改写为
$pic = strtr(substr($title['picture'], 2), '\\', '/');
echo "<td width='10%'><img src=$pic alt=\"images\"/></td>";
echo "<td width='10%'><img src='".$title[picture]."'></td>";
echo "<td width='10%'><img src='".$title[picture]."'></td>";