使用选中的文本框值进行查询 [英] query using textbox value selected

查看:61
本文介绍了使用选中的文本框值进行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在为我的文本框使用scriptaculous自动完成功能,它完全正常

i已经使server.php获取ul列表中的值并且它在主窗体上正确显示但是在从文本框中选择值之后我想进一步查询我的数据库以获取更多细节,具体取决于该值


但我不喜欢虽然我的表有记录,但是没有任何记录。

如果我在showcode函数中警告ar值它显示正确值的行但是没有显示int div容器

if itry在主窗体中创建该表,获取$ c_cde的值,然后创建现有数据的行,它不显示任何行

而不是生成服务器中的行.php

,因为它没有得到$ c_Cde值,我检查了警告它


我哪里错了

我的代码在这里

[PHP]< form method =" get">

< table id =" tbl">

< tr>

< td bordercolor ="#669999">

< label>< strong>< font size =" 3">选择国家< / strong>< / label>< / td>

< td colspan =" 11" BORDERCOLOR ="#669999">

< input type =" text" c_name = QUOT; c_name" ID = QUOT; c_name"大小= QUOT; 40"类= QUOT; dlight"自动填充= QUOT;脱" onblur =" showCode(this.value);">

< div id =" hint">< / div>

< script类型= QUOT;文本/ JavaScript的">

新的Ajax.Autocompleter(" c_name"," hint"," server.php");

< / script>

< input type =" text"名称= QUOT; c_code" ID = QUOT; COUNTRYCODE"大小= QUOT; 8英寸类= QUOT; dlight"值= QUOT;< = $ c_code>?" >

< div id =" tbl1">< / div>

< tr>< td>< input type =" text" ;名称= QUOT; isdcode" ID = QUOT; isdcode" value ="<?= $ misdcode?>">< / td>

< td>< input type =" text"名称= QUOT;大陆" ID = QUOT;大陆" value ="<?= $ mcontinent?>">< / td>< / tr>

< / table>

< / form> [/ PHP]


和我的server.php如果如下


[PHP]<?php

包括(../ include / con.php);

$ sql ="选择c_code,来自countrymaster的c_name,其中c_name类似于''%" 。 $ _GET [''c_name'']。 "%''" ;;

$ rs = $ DB_site->查询($ sql);

?>

< ; ul>

<? while($ data = $ DB_site-> fetch_array($ rs)){?>

< li><? echo stripslashes($ data [''c_name'']。" - "。$ data [''c_cde'']);

?>< / li>

<? }?>

< / ul>

< ;?

if($ _ GET [''c_name'']!=""){

$ mc_name = $ _GET [''c_name''];

$ mc_cde = $ _ GET [''c_cde''];

echo" |"。$ mc_cde。" |" ;;

}

$ sql1 =" select * from countrydetails c_cde =''"。$ mc_cde。"''" ;;

$ db_query_pricelist = $ DB_site->查询($ sql1);

while($ rs = $ DB_site-> fetch_array($ db_query_rs)){

$ misdcode = $ rs [isdcode''];

$ mcontinent = $ rs [''continent''];

?>

< tr>< td><?= $ misdcode;?>< / td>

< td><?= $ mcontinent;?>< ; / td>

< / tr>

<? }?> [/ PHP]



showcode函数中的

展开 < span class =codeDivider> | 选择 | Wrap | Line数字

解决方案

c_cde它然后创建现有数据的行,它不显示任何行

而不是生成行int他server.php

因为它没有得到


c_Cde值我检查了它提醒它


我错在哪里

我的代码在这里

[PHP]< form method =" get">

<标签le id =" tbl">

< tr>

< td bordercolor ="#669999">

< label>< strong>< font size =" 3">选择国家< / strong>< / label>< / td>

< td colspan =" 11" BORDERCOLOR ="#669999">

< input type =" text" c_name = QUOT; c_name" ID = QUOT; c_name"大小= QUOT; 40"类= QUOT; dlight"自动填充= QUOT;脱" onblur =" showCode(this.value);">

< div id =" hint">< / div>

< script类型= QUOT;文本/ JavaScript的">

新的Ajax.Autocompleter(" c_name"," hint"," server.php");

< / script>

< input type =" text"名称= QUOT; c_code" ID = QUOT; COUNTRYCODE"大小= QUOT; 8英寸类= QUOT; dlight"值= QUOT;< =

c_code>?" >

< div id =" tbl1">< / div>

< tr>< td>< input type =" text" ;名称= QUOT; isdcode" ID = QUOT; isdcode"值= QUOT;< =

Hi,
I''m using scriptaculous autocomplete for my text box and it works perfectly ok
i have made server.php for fetching the values in the ul list and it is shown correctly on the main form but after selection of the value from the text box i want to query my database further for some more details depending on that value

but i don''t get any records although my table has records.
if i alert ar values in showcode function it shows rows with values correctly but doesnt show int he div container
if itry to create that table in the main form taking the values of $c_cde it and then create rows of the existing data it doesnt show any rows
instead of generating the rows int he server.php
because it doesnt get $c_Cde value there i checked alerting it


where am i going wrong
my code goes here
[PHP]<form method="get">
<table id="tbl">
<tr>
<td bordercolor="#669999">
<label><strong><font size="3">Select country</strong></label></td>
<td colspan="11" bordercolor="#669999">
<input type="text" c_name="c_name" id="c_name" size="40" class="dlight" autocomplete="off" onblur="showCode(this.value);">
<div id="hint"></div>
<script type="text/javascript">
new Ajax.Autocompleter("c_name","hint","server.php");
</script>
<input type="text" name="c_code" id="countrycode" size="8" class="dlight" value="<?=$c_code?>" >
<div id="tbl1"></div>
<tr><td><input type="text" name="isdcode" id="isdcode" value="<?=$misdcode?>"></td>
<td><input type="text" name="continent" id="continent" value="<?=$mcontinent?>"></td></tr>
</table>
</form>[/PHP]

and my server.php if as follows


[PHP]<?php
include("../include/con.php");
$sql = "select c_code,c_name from countrymaster where c_name like ''%" . $_GET[''c_name''] . "%''";
$rs = $DB_site->query($sql);
?>
<ul>
<? while($data = $DB_site->fetch_array($rs)) { ?>
<li><? echo stripslashes($data[''c_name'']."-".$data[''c_cde'']);
?></li>
<? } ?>
</ul>
<?
if($_GET[''c_name'']!=""){
$mc_name=$_GET[''c_name''];
$mc_cde=$_GET[''c_cde''];
echo "|".$mc_cde."|";
}
$sql1="select * from countrydetails where c_cde=''".$mc_cde."''";
$db_query_pricelist=$DB_site->query($sql1);
while($rs=$DB_site->fetch_array($db_query_rs)){
$misdcode=$rs[isdcode''];
$mcontinent=$rs[''continent''];
?>
<tr><td><?=$misdcode;?></td>
<td><?=$mcontinent;?></td>
</tr>
<? } ?>[/PHP]





in showcode function

Expand|Select|Wrap|Line Numbers

解决方案

c_cde it and then create rows of the existing data it doesnt show any rows
instead of generating the rows int he server.php
because it doesnt get


c_Cde value there i checked alerting it


where am i going wrong
my code goes here
[PHP]<form method="get">
<table id="tbl">
<tr>
<td bordercolor="#669999">
<label><strong><font size="3">Select country</strong></label></td>
<td colspan="11" bordercolor="#669999">
<input type="text" c_name="c_name" id="c_name" size="40" class="dlight" autocomplete="off" onblur="showCode(this.value);">
<div id="hint"></div>
<script type="text/javascript">
new Ajax.Autocompleter("c_name","hint","server.php");
</script>
<input type="text" name="c_code" id="countrycode" size="8" class="dlight" value="<?=


c_code?>" >
<div id="tbl1"></div>
<tr><td><input type="text" name="isdcode" id="isdcode" value="<?=


这篇关于使用选中的文本框值进行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆