表格横排显示数据库资料
表格横排显示数据库资料
CREATE TABLE `fnd` (
`id` int(255) NOT NULL auto_increment,
`fndName` varchar(255) collate latin1_general_ci NOT NULL default '',
`fndPrice` varchar(255) collate latin1_general_ci NOT NULL default '',
`type` varchar(255) collate latin1_general_ci NOT NULL default '',
`picture` longblob NOT NULL,
PRIMARY KEY (`id`)
)
<html>
<head>
</head>
<body>
<link href="set.css" rel="stylesheet" type="text/css">
<?php
include('connection.php');
$str = "SELECT * FROM fnd ";
$conn1=mysql_query($str);
while(list($id,$fndName,$fndPrice)= mysql_fetch_row($conn1))
{
?>
<table width="400" border="0" cellpadding="0"cellspacing="0" bordercolor="#FF0000"style="float:left;">
<tr>
<td colspan="2"><?php echo "<img id='mypic' src='editfnd2.php?id=$id'>"?> </td>
</tr>
<tr>
<td width="91">Food Name: </td>
<td width="409"><?php echo $fndName;?></td>
</tr>
<tr>
<td width="91">Food Price:</td>
<td>RM <?php echo $fndPrice;?></td>
</tr>
</table>
</tr></table>
<p>
<?php
}
?>
</p>
</body>
</html>
`id` int(255) NOT NULL auto_increment,
`fndName` varchar(255) collate latin1_general_ci NOT NULL default '',
`fndPrice` varchar(255) collate latin1_general_ci NOT NULL default '',
`type` varchar(255) collate latin1_general_ci NOT NULL default '',
`picture` longblob NOT NULL,
PRIMARY KEY (`id`)
)
<html>
<head>
</head>
<body>
<link href="set.css" rel="stylesheet" type="text/css">
<?php
include('connection.php');
$str = "SELECT * FROM fnd ";
$conn1=mysql_query($str);
while(list($id,$fndName,$fndPrice)= mysql_fetch_row($conn1))
{
?>
<table width="400" border="0" cellpadding="0"cellspacing="0" bordercolor="#FF0000"style="float:left;">
<tr>
<td colspan="2"><?php echo "<img id='mypic' src='editfnd2.php?id=$id'>"?> </td>
</tr>
<tr>
<td width="91">Food Name: </td>
<td width="409"><?php echo $fndName;?></td>
</tr>
<tr>
<td width="91">Food Price:</td>
<td>RM <?php echo $fndPrice;?></td>
</tr>
</table>
</tr></table>
<p>
<?php
}
?>
</p>
</body>
</html>
editfnd2.php 显示图片的
<?
if(isset($_GET['id']))
{
$id = $_GET['id'];
include("connection.php");
$sql = "select picture from fnd where id='$id'";
$result = mysql_query($sql);
$picpic = MYSQL_RESULT($result,0,"picture");
echo $picpic;
}
?>
if(isset($_GET['id']))
{
$id = $_GET['id'];
include("connection.php");
$sql = "select picture from fnd where id='$id'";
$result = mysql_query($sql);
$picpic = MYSQL_RESULT($result,0,"picture");
echo $picpic;
}
?>
回复: 表格横排显示数据库资料
css文件调图片大小:
#mypic {width:250px; height:250px;}
______________________________________________________________________
connection.php:
<?php
import_request_variables("GP","");
$connection=mysql_connect("127.0.0.1","root","")
or die("Could not connect");
mysql_select_db("yama",$connection)
or die("Could not select database");
?>
#mypic {width:250px; height:250px;}
______________________________________________________________________
connection.php:
<?php
import_request_variables("GP","");
$connection=mysql_connect("127.0.0.1","root","")
or die("Could not connect");
mysql_select_db("yama",$connection)
or die("Could not select database");
?>
您在这个论坛的权限:
您不能在这个论坛回复主题