Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>news list</title>
- </head>
- <body>
- <div id="newslist">
- <?php
- $db = new PDO( 'mysql:host=localhost;dbname=web;charset=utf8', 'root', '');
- $rs = $db->query("select no, title from news");
- if( $rs->rowCount() ) {
- $rows = $rs->fetchAll(PDO::FETCH_ASSOC);
- foreach($rows as $r) {
- echo $r['title']."<br>";
- }
- }
- //$count = $db->exec("DELETE FROM news WHERE no > 9");
- //print("deleted record : " . $count . "<br>");
- $count = $db->exec("insert into news set title='hello webdesign',content='hahahahahahahahahahhaahahah'");
- print("inserted record : " . $count);
- ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment