从数据库中获取数据并在html上打印

时间:2016-07-18 15:03:46

标签: php

我正在编写一个code,它应该从image获取数据database和其他信息,然后在页面上打印数据。 image,应该从database获取,并在框中打印image,并在各自的区域打印其他信息。

代码看起来像这样

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<meta name="generator" content="Web Page Maker">
<style type="text/css">
/*----------Text Styles----------*/
.ws6 {font-size: 8px;}
.ws7 {font-size: 9.3px;}
.ws8 {font-size: 11px;}
.ws9 {font-size: 12px;}
.ws10 {font-size: 13px;}
.ws11 {font-size: 15px;}
.ws12 {font-size: 16px;}
.ws14 {font-size: 19px;}
.ws16 {font-size: 21px;}
.ws18 {font-size: 24px;}
.ws20 {font-size: 27px;}
.ws22 {font-size: 29px;}
.ws24 {font-size: 32px;}
.ws26 {font-size: 35px;}
.ws28 {font-size: 37px;}
.ws36 {font-size: 48px;}
.ws48 {font-size: 64px;}
.ws72 {font-size: 96px;}
.wpmd {font-size: 13px;font-family: Arial,Helvetica,Sans-Serif;font-style: normal;font-weight: normal;}
/*----------Para Styles----------*/
DIV,UL,OL /* Left */
{
 margin-top: 0px;
 margin-bottom: 0px;
}
</style>

<style type="text/css">
div#container
{
    position:relative;
    width: 1229px;
    margin-top: 0px;
    margin-left: auto;
    margin-right: auto;
    text-align:left; 
}
body {text-align:center;margin:0}
</style>

</head>
<body>
<?php
include 'config.php';
if(isset($_GET['submit']))
{

    $con = mysqli_connect($hostname, $user, $password, $db) or die('cannot connect');
    $number = mysqli_real_escape_string($con,$_POST['number']);
    $sql = "SELECT * FROM personaz WHERE number = $number";
    $sth = $db->query($sql);
    $result = mysqli_fetch_array($sth);

    $imagea = 
}
?>
<div id="container">
<form name="people" method="GET" action="info2.php" style="margin:0px">
<input name="number" type="text" style="position:absolute;width:200px;left:399px;top:133px;z-index:3">
</form>

<div id="text1" style="position:absolute; overflow:hidden; left:236px; top:91px; width:150px; height:26px; z-index:1">
<div class="wpmd">
<div><font class="ws16">People Data</font></div>
</div></div>

<!--[if IE]><div id="table1" style="position:absolute; overflow:hidden; left:782px; top:98px; width:187px; height:177px; z-index:2; border:#969696 1px solid"><![endif]-->
<!--[if !IE]>--><div id="table1" style="position:absolute; overflow:hidden; left:782px; top:98px; width:185px; height:175px; z-index:2; border:#969696 1px solid"><!--<![endif]-->

<div class="wpmd">
<div><TABLE bgcolor="#FFFFFF" border=0 bordercolorlight="#C0C0C0" bordercolordark="#808080">
<TR valign=top>
<TD width=220 height=203><BR>
<?php echo $image?>
</TD>
</TR>
</TABLE>
</div>
</div></div>

<div id="text2" style="position:absolute; overflow:hidden; left:242px; top:134px; width:150px; height:18px; z-index:4">
<div class="wpmd">
<div>Enter Tel Number :</div>
</div></div>

<div id="text3" style="position:absolute; overflow:hidden; left:242px; top:186px; width:150px; height:32px; z-index:5">
<div class="wpmd">
<div>Fullname : </div>
</div></div>

<div id="text4" style="position:absolute; overflow:hidden; left:238px; top:232px; width:77px; height:32px; z-index:6">
<div class="wpmd">
<div>EMail : </div>
</div></div>

<div id="text5" style="position:absolute; overflow:hidden; left:235px; top:281px; width:150px; height:32px; z-index:7">
<div class="wpmd">
<div>Telephone : </div>
</div></div>

<div id="hr1" style="position:absolute; overflow:hidden; left:205px; top:379px; width:819px; height:16px; z-index:8">
<hr size=2 width=819>
</div>

</div>

</body>
</html>

我该怎么做?绝望地需要帮助。

1 个答案:

答案 0 :(得分:0)

<img src="data:image/jpeg;base64,<?php echo base64_encode($result['pic']) ?>"/>

您必须使用从数据库获取的图像BLOB替换$result['pic']