数据库里面 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>";
?>
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>";