asimryu

news list

May 20th, 2014
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>news list</title>
  6. <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/sunny/jquery-ui.css">
  7. <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
  8. <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  9. </head>
  10. <body>
  11. <div id="newslist">
  12. <?php
  13.     $conn = @mysql_connect("localhost","root","");
  14.     @mysql_select_db("web",$conn);
  15.     @mysql_query("set names utf8");
  16.     $sql = "select no, title from news";
  17.     $rs = @mysql_query($sql);
  18.     while( $row = @mysql_fetch_array($rs) ) {
  19. ?>     
  20.     <a href="<?php echo $row['no'];?>"><?php echo $row['title'];?></a><br>
  21. <?php
  22.     }
  23. ?>
  24. </div>
  25. <script>
  26.     $("#newslist a").click(
  27.         function(event){
  28.             event.preventDefault();
  29.             var link = $(this).attr("href");
  30.             alert(link);
  31.         }
  32.     );
  33. </script>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment