开发者

asynchronous data with mysql php?

I do have a code which shows number of data in database. I want to send this data to browser in real time or in between couple of seconds using ajax or any other method...

My code:

$db = mysql_connec开发者_Python百科t($db_host, $db_username, $db_password) or die("Could not connect.");
mysql_select_db($databse_name,$db)or die(mysql_error()); 
$result = mysql_query("SELECT * FROM table")or die(mysql_error());
$num_rows = mysql_num_rows($result);
echo "$num_rows\n";


If you're using jQuery and that php code is in a file called your_code.php, you could do something like this:

$('#my_button').click(function() {
    $.ajax({
        url: "your_code.php",
        success: function(data) {
            $('#my_div').html(data);
        }
    });
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜