English 中文(简体)
露面新闻与jquery和php
原标题:show news live with jquery and php

我有这样的情况:

<input id="num" type="text">

// var num = $("#num").val();
< ?php
$sql=mysql_query("SELECT * FROM news WHERE 
id= num //???
"); 

while($row=mysql_fetch_array($sql))
{
?>

< div id="main">
< ?php echo $row[ title ]; ?>
< ?php echo $row[ body ]; ?>
< /div>
< ?php
}

我如何用 input语撰写文章,在不更新网页的情况下观看新的新闻? 我知道,我必须使用 j和ja。 i 只能做 j,但可以把它与购买力平价结合起来。

感谢!

最佳回答

你们是否考虑使用Json 、Jquery 和PHP共同使用吗? 在某些间隔时间用 j子打一页。 这可能给一些要点。

显示新闻。

 <input id="num"><input type="submit" onclick="loadNews()"/>
  <div id= content ></div>
<script>
     function loadNews(){
         $.getJSON("http://www.YourSite.com/GetNews.php?id=" + $("#num").val(), 
              function(data) {
                  $( #content ).html( Latest News:   + data.news +  <br/><br/> );
              }); 
         //setTimeout(loadNews(),5000); use this if you want to refresh ever 10seconds
      }
</script>

GetNews.php

< ?php
$sql=mysql_query("SELECT * FROM news WHERE id= num)
Execute query....
echo  {news:  . result .  } ;
?>
问题回答

暂无回答




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签