Hi all,
So I have 2 files where one is an ajax script that calls another file that does some mysql database query.
What is the best way to echo out multiple recordset rows to ajax?.
Please see the source code below:
ajax code:
<form name="form1" method="post">
Please enter name <input type="text" id="name" name="name" />
<input type="submit" value="get data" name="submit" id="submit"/>
</form>
<div id="output"></div>
<script type="text/javascript">
$('#submit').click(function(){
$.ajax({
url:'data.php',
data: 'firstname=' + name,
type:'post',
success: function(data) {
$('#output').html(data);
}
});
});
data.php code
<?php
$firstname = $_post['firstname'];
$query_Recordset1 = "SELECT * FROM cust WHERE name='$firstname'";
$Recordset1 = mysql_query($query_Recordset1, $tests) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
echo $row_Recordset1;
?>