我有一个关于多输出交替只有一个搜索引擎的问题....我在下面有这个场景..
情景:
textarea1(id='content')
textarea2(id='content1')
textarea3('content2')
注意:我只使用了一个搜索引擎..
请帮帮我:( 谢谢你,祝你有美好的一天! 以下是我的代码
表:用户
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";
}
}