帮忙看下这个代码吧 急用 谢谢

xiaridf 2009-08-10 08:39:20
是这样的 是在index中输入一段文字 在result中返回结果,result要查询数据库,现在可以把数据库中的信息都显示,但是我想让它只显示与tqym中返回结果相同的数据 要怎么改下 谢谢 我是用dreamweaver做的 可能用dreamweaver打开比较清晰

代码
tqym.php:

<?
$wz = $_POST['wzsr'];
function get_domain($url)
{
......
}// end function
$ym = get_domain($wz);
?>

result.php:

<?php require_once('Connections/dl.php'); ?>
<?php include"tqtm.php"; ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_dl, $dl);
$query_Recordset1 = "SELECT * FROM ym";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $dl) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<?php do { ?>
<table width="200" border="0">
<tr>
<td><?php echo $row_Recordset1['ym']; ?></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>zh:</td>
<td><?php echo $row_Recordset1['zhanghao']; ?></td>
<td>是</td>
</tr>
<tr>
<td>mm:</td>
<td><?php echo $row_Recordset1['mima']; ?></td>
<td>否</td>
</tr>
</table>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?></body>
</html>
<?php
mysql_free_result($Recordset1);
?>
...全文
126 点赞 收藏 12
写回复
12 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
YHL27 2009-08-14
sf!!
回复
xiaridf 2009-08-13
还是显示错误 <?php include"tqtm.php"; ?>写在文件开头应该没错吧
回复
江南昆虫 2009-08-13
$query_Recordset1 = "SELECT * FROM ym Where ym=$ym";

PS.你以后最好别把表和字段起相同的名字
回复
ldyanstar 2009-08-13
楼主搞点重点贴,看的头晕眼花

回复
xiaridf 2009-08-12
我是用Dreamweaver做的 自动生成的 能再详细点吗 我用where $ym 就无法显示该页了
回复
总哈哈 2009-08-12
执行一条Where语句就可以了,不知道楼主写这么多SQL干嘛?还有从数据库查询以后,不要do...while,而是while....do
回复
xiaridf 2009-08-12
补充:数据表:ym zhanghao mima
就是result。php在查询数据库的时候要匹配tqym.php中%ym这个变量的内容来查找
回复
xiaridf 2009-08-12
谁会啊 帮帮忙啊
回复
xiaridf 2009-08-12
这是所有源代码啊 能上传附件吗

这样说吧 应该是改这句 $query_Recordset1 = "SELECT * FROM ym";
还有一个文件tqym.php 处理结果是一个字符串 $ym = "..."; 我要在result.php文件中查询时匹配这个字符串怎么写?
<?php include"tqtm.php"; ?>
<?
......
$query_Recordset1 = "SELECT * FROM ym Where $ym";
......
?>
这样吗?
回复
jlzan1314 2009-08-12
你在芜湖工作过,还是个外企?
回复
CYBEREXP2008 2009-08-12
highlight_string('<?
$wz = $_POST['wzsr'];
function get_domain($url)
{
......
}// end function
$ym = get_domain($wz);
?>

result.php:

<?php require_once('Connections/dl.php'); ?>
<?php include"tqtm.php"; ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_dl, $dl);
$query_Recordset1 = "SELECT * FROM ym";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $dl) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档 </title>
</head>
<body>
<?php do { ?>
<table width="200" border="0">
<tr>
<td> <?php echo $row_Recordset1['ym']; ?> </td>
<td>  </td>
<td>  </td>
</tr>
<tr>
<td>zh: </td>
<td> <?php echo $row_Recordset1['zhanghao']; ?> </td>
<td>是 </td>
</tr>
<tr>
<td>mm: </td>
<td> <?php echo $row_Recordset1['mima']; ?> </td>
<td>否 </td>
</tr>
</table>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </body>
</html>
<?php
mysql_free_result($Recordset1);
?>')

楼主:没法给你回啊!!你什么都不讲,要我们来改你这个,啥都不知道啊
回复
tfxg 2009-08-11
回复
发动态
发帖子
基础编程
创建于2007-09-28

2.1w+

社区成员

从PHP安装配置,PHP入门,PHP基础到PHP应用
申请成为版主
社区公告
暂无公告