|
 |
|
เขียน php ดึงข้อมูลจากฐานข้อมูลมาแสดงบน html ไม่ได้คับ |
|
 |
|
|
 |
 |
|
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<link href="Web/site/style.css" rel="stylesheet" type="text/css" />
<link href="Web/site/layout.css" rel="stylesheet" type="text/css" />
</head>
<body id="page2">
<?php
$con = mysql_connect("localhost","root","123456");
if (!$con)
{
die("Could not connect: " . mysql_error());
}
mysql_select_db("tni_assets");
$sql="SELECT number,ID,name,position,location FROM computer_inventory";
$result = mysql_query($sql);
?>
<div class="tall_top">
<div id="main">
<div id="left_side">
<div class="indent">
<img class="title" alt="" src="Web/site/images/2_t1.gif" /><br />
<br />
<h4> </h4>
</div>
</div>
<div id="right_side">
<div class="wrapper">
<div id="header">
<div class="row_1">
<div class="fleft"></div>
<div class="fright">
<div class="indent">
<a href="Web/site/index.html"><img alt="" src="Web/site/images/header_link1.gif" /></a><a href="#"><img alt="" src="Web/site/images/header_link2.gif" /></a>
</div>
</div>
</div>
<div class="row_2">
<div class="left">
<div class="right">
<div class="indent">
<a href="Web/site/index.html"><img alt="" src="Web/site/images/but_0.jpg" /></a><img alt="" src="Web/site/images/spacer.gif" width="11" height="1" /><img alt="" src="Web/site/images/header_sep.jpg" /><img alt="" src="Web/site/images/spacer.gif" width="8" height="1" /><a href="Web/site/index-1.html"><img alt="" src="Web/site/images/but_1.jpg" /></a><img alt="" src="Web/site/images/spacer.gif" width="8" height="1" /><img alt="" src="Web/site/images/header_sep.jpg" /><img alt="" src="Web/site/images/spacer.gif" width="8" height="1" /><a href="Web/site/index-2.html"><img alt="" src="Web/site/images/but_2.jpg" /></a><img alt="" src="Web/site/images/spacer.gif" width="8" height="1" /><img alt="" src="Web/site/images/header_sep.jpg" /><img alt="" src="Web/site/images/spacer.gif" width="8" height="1" /><a href="Web/site/index-3.html"><img alt="" src="Web/site/images/but_3.jpg" /></a><img alt="" src="Web/site/images/spacer.gif" width="8" height="1" /><img alt="" src="Web/site/images/header_sep.jpg" /><img alt="" src="Web/site/images/spacer.gif" width="10" height="1" /><a href="Web/site/index.html"><img alt="" src="Web/site/images/but_5.jpg" /></a><img alt="" src="Web/site/images/spacer.gif" width="11" height="1" /></div>
</div>
</div>
</div>
</div>
<div id="content">
<div class="row_1" style="width:100%;">
<div class="col_1">
<div class="indent">
<div class="block">
<div class="l_t">
<div class="r_t">
<div class="r_b">
<div class="l_b">
<div class="ind">
<div class="line_hor1"><strong><font color="red" size="5">EDIT DATA/DELETE DATA</font></strong></div>
<?php echo "<center><table border='1' cellspecing='0' cellpadding='0' width='80%'>";
echo "<tr><th >number</th><th >ID</th><th>Name</th><th>Position</th><th>Location</th><th>DELETE</th><th>EDIT</th></tr>";
$i=1;
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>".$row["number"]."</td>";
echo "<td>".$row["ID"]."</td>";
echo "<td>".$row["name"]."</td>";
echo "<td>".$row["position"]."</td>";
echo "<td>".$row["location"]."</td>";
echo "<td class='td1'><a href='deleteproduct.php?code=".$row['code']."'><img src='picture/delete.jpg' alt='Delete product code : ".$row['code']."'/></a></td>";
echo "<td class='td1'><a href='updateproduct.php?code=".$row['code']."'><img src='picture/edit.jpg' alt='Edit product code : ".$row['code']."'/></a></td>";
echo "</tr>";
$i++;
}
echo "</table>";
mysql_close($con); ?>
<p> </p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
</div>
<div class="clear"></div>
<div id="footer">
<div class="fleft">
<div class="indent"></div>
</div>
<div class="fright">
<div class="indent"></div>
</div>
<div class="clear"></div>
</div>
</div>
</body>
</html>
คือผมต้องการดึงข้อมูล number,ID,name,position,location FROM computer_inventory แต่มาแสดงบนเบราเซอร์มันขึ่้นแบบนี้คับ
"; echo ""; $i=1; while($row = mysql_fetch_array($result)) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; $i++; } echo "
number ID Name Position Location DELETE EDIT
".$row["number"]." ".$row["ID"]." ".$row["name"]." ".$row["position"]." ".$row["location"]."
"; mysql_close($con); ?>
อยู่ตรงกลางเว็บ ข้อมูลก็ไม่ขึ้น ไม่ทราบว่าผมเขียนอะไรผิดตรงไหน ช่วยชี้แนะทีคับ ขอบคุณมากคับ
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2011-01-22 11:57:39 |
By :
cloudsphere |
View :
2067 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขึ้น แค่ นี้ กลาง จอ ไม่มีไร อีก เลยหรอ ครับ
|
 |
 |
 |
 |
Date :
2011-01-22 13:24:30 |
By :
wisutsak |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|