troubleshooting Question

Php - how to do multiple search w/ multiple output alternately

Avatar of Jhovyn Marcos
Jhovyn Marcos asked on
PHPMySQL ServerJavaScriptjQuery
7 Comments1 Solution178 ViewsLast Modified:
I have a question regarding on multiple output alternately with only one search engine....I have this scenario below..

Scenario:

    First search the data. The output will go in textarea1(id='content')
    Second search the data. The output will go in textarea2(id='content1')
    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! Below is my code

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


      

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

Scenario:

    First search the data. The output will go in textarea1(id='content')
    Second search the data. The output will go in textarea2(id='content1')
    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! Below is my code

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
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";
}
}
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros