Hi guys
I’m just starting out in PHP. I would like to retrieve some data from the database and display it on my webpage
This is my code so far but obviously it does not work…
any ideas on how to correct this?
[php]
<?php //connection variables $host = "localhost"; $usernamehost = "admin"; $passwordhosts = "admin"; $db_name = "wordpress"; //connection to the db_name mysql_connect("$host", "$usernamehost", "$passwordhosts") or die ("cannot connect"); //select the db_name mysql_select_db("$db_name") or die ("cannot select DB"); ?> <?php $sql = "SELECT post_title, post_excerpt FROM wp_posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date_gmt DESC LIMIT 0, 9" while ($data = mysql_fetch_array($sql)) { ?><?php echo $data["post_title"]; ?>
<?php echo $data["post_excerpt"]; ?>
<?php endforeach; ?>
[/php]