这是显示我的问题的网站
http://teetimeqc.com/paypage.php
我想显示 1 整行与列 'cust_no' 上的搜索查询词完全匹配
其他列是“prog_id”、“balance”、“cust5_id”
因此,用户搜索“140594”,如果它与该行的“cust_no”完全匹配,则显示整个1行。
所以他们看到这样的结果:
ID# Prog ID# Cust No# Balance #
更新代码!
感谢到目前为止 jtherman 的帮助
<code>
<?php
$db_host="***";
$db_username="****";
$db_password="****";
$db_name="***";
$db_tb_name="cust";
$db_tb_atr_name="cust_no";
$db_prog="prog_id";
$db_bal="balance";
mysql_connect("****","*******","*****");
mysql_select_db("db461563732");
$query=mysql_real_escape_string($_GET['query']);
$query_for_result=mysql_query("SELECT * FROM $db_tb_name WHERE
$db_tb_atr_name = '".$query."'");
echo "<h2>Search Results</h2>";
while($data_fetch=mysql_fetch_array($query_for_result))
echo ($data_fetch[$db_tb_atr_name]);
echo ($data_fetch[$db_prog]);
mysql_close();
?>
这是桌子的样子;Cust5_ID 并不重要,它只是我用作主键的自动增量值.....我应该将主键更改为“cust_no”吗?:
TABLE `cust`
(
`cust5_id` Integer auto_increment primary key,
`prog_id` Integer not null,
`cust_no` Integer null,
`balance` Decimal(12, 2) null
) DEFAULT CHARACTER SET utf8 ENGINE=InnoDB;
INSERT INTO `cust`
(`cust5_id`,`prog_id`,`cust_no`,`balance`)
VALUES
(1,217770,145094,-178.01),
(2,219885,145113,-390.86),
(3,219888,145164,-206.55),
(4,226227,145279,0),
(5,227700,145340,0),
(6,219911,145344,0),
(7,227795,145410,-44.1);