Php - 如何交替多次搜索多次搜索 [英] Php - how to do multiple search w/ multiple output alternately

查看:104
本文介绍了Php - 如何交替多次搜索多次搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天!我有一个关于多个输出交替只有一个搜索引擎的问题....我有下面这个场景..



场景:

1.首先搜索数据。输出将进入textarea1(id ='content')

2.第二次搜索数据。输出将进入textarea2(id ='content1')

3.第三次搜索数据。输出将输入textarea3('content2')



注意:我只使用了一个搜索引擎..



请帮帮我:(

谢谢你,祝你有愉快的一天!



B



我尝试过:



表:用户

 CREATE TABLE users 
(id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50),
age INT)





index.php

< html> 
< head>

< script type =text / javascriptsrc =jquery.js>< / script>

< script type =text / javascript>
function get (){
$ .post('data.php',{name:form.search.value},
function(output){
$('#content')。html(输出).show();
$('#content1')。html(输出).show();
$('#content2')。html(输出).show();
});
}

< / script>
< / head>
< body>
< p>
< form name =form& gt;
< input type =textname =search>
< input type =buttonvalue =GetonClick =get();>
< / form>
< div>
< textarea id ='content'cols ='15'rows ='5'>< / textarea>
< textarea id ='content1'cols = '15'rows ='5'>< / textarea>
< textarea id ='content2'cols ='15'rows ='5'>< / textarea>
< / div>
< / p>

< / body>
< / html>





data.php

< ;?php 
需要'connection.php';

$ name = mysql_real_escape_string($ _ POST ['name']);

if($ name == NULL)
echo请输入名称;
else
{
$ age = mysql_query(SELECT age FROM users WHERE memberName ='$ name');
$ age_num_rows = @mysql_num_rows($ age);

if($ age_num_rows == 0)
echo名称不存在;

else
{
$ age = mysql_result($ age,0);
echo$ name的年龄是$ age;
}
}

解决方案

.post('data.php',{name:form.search。 value},
function(output){


('#content')。html(output).show();


( '#内容1')的html(输出).show();

Good Day! I have a question regarding on multiple output alternately with only one search engine....I have this scenario below..

Scenario:
1. First search the data. The output will go in textarea1(id='content')
2. Second search the data. The output will go in textarea2(id='content1')
3. Third search the data. The output will go in textarea3('content2')

NOTE: I only used one search engine..

Please help me :(
Thank you and have a nice day!

B

What I have tried:

Table: users

CREATE TABLE users
(id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50),
age INT)



index.php

<html>
<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">
function get() {
$.post('data.php', { name: form.search.value },
function(output) {
$('#content').html(output).show();
$('#content1').html(output).show();
$('#content2').html(output).show();
});	
}
	
</script>
</head>
<body>
<p>
<form name="form">
	<input type="text" name="search">
	<input type="button" value="Get" onClick="get();">  
</form>
<div>
<textarea id='content' cols='15' rows='5'></textarea>
<textarea id='content1' cols='15' rows='5'></textarea>
<textarea id='content2' cols='15' rows='5'></textarea>
</div>
</p>

</body>
</html>



data.php

<?php
require 'connection.php';

$name = mysql_real_escape_string($_POST['name']);

if($name==NULL)
echo "Please enter a name";
	else
	  {
		$age = mysql_query("SELECT age FROM users WHERE memberName='$name'");
		$age_num_rows = @mysql_num_rows($age);
		
	if($age_num_rows==0)
		echo "Name does not exists";
		
			else
			  {
				$age = mysql_result($age, 0);	
				echo "$name's age is $age";
			  }
}

解决方案

.post('data.php', { name: form.search.value }, function(output) {


('#content').html(output).show();


('#content1').html(output).show();


这篇关于Php - 如何交替多次搜索多次搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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