View Full Version : replace echo from php file and use success to display

03-01-2013, 08:22 PM
i pull info from mysql database and display it to the user to see if that time and date is available,

normaly i use just a typical echo to display the results, but as i want to keep it all on the same page so i dont have to do a refresh i am using ajax,

so now my echo is no good,

so how would i put the info on using the success?

iv tried a few things but dident really understand it all that much and failed.

as my php would be,

$data=mysql_query("select * from $tbl_name WHERE dates='$compdate' AND time='$newtimes'");
$row = mysql_fetch_array($data);
$fetched = $row['dates'] . $row['time'];
if ($fetched == "") {
echo "the date: $compdate and time: $newtimes is available<br />";
echo "the date: $compdate and time: $newtimes is NOT available<br />";

and my ajax as it stands

$("form#chkreadings").submit(function() {
// we want to store the values from the form input box, then send via ajax below
var fpeople = $('#people').attr('value');
var flistday = $('#listday').attr('value');
var flistmonth = $('#listmonth').attr('value');
var flisthour = $('#listhour').attr('value');
var flistampm = $('#listampm').attr('value');
type: "POST",
url: "checkreadings.php",
data: "people=" + fpeople + "listday=" + flistday + "listmonth=" + flistmonth + "listhour=" + flisthour + "listampm=" + flistampm,
success: function(){

return false;


the success function i just posted is just from an example so how would i change that to echo what is from the php file?