Click here to Skip to main content
15,072,311 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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";
			  }
}
Posted
Updated 14-Mar-17 16:04pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900