Hi folks, long time no hear.
I know Laserlight is going to kill me as I have already asked a similar question, but i still haven;t got round to putting into action her solution and now I have deleted the email with the link to it and I want to do a similar thing for a different function, but I will definitely be doing this.
I run a blog on my website, currenyl I create a new html page for every post manually. But I want to start putting my posts into my MySql and pulling them out onto the blog page. For a start I am well rusty as I have been learning about Java lately, so please tell me if I ham supposted to have brackets round my query's and inside or outside the quotes
So I would do after the connection which I'm okay with,
I would put this before even the html
<? $mysql_query = "SELECT * FROM the_db ORDER BY ID DESC";
$nrows = mysql_num_rows(mysql_query);
?>
I just need to know how to select the most recent post.
Maybe:
<?
$post_pull = "SELECT FROM the_db WHERE ID = $nrows";
$post = mysql_fetch_array(post_pull);
$post_pull2 = "SELECT FROM the_db WHERE ID = $nrows-1";
$_post2= mysql_fetch_array(post_pull2);?>
for the Headline
<div id="posthead">
<? echo $post['title']; ?>
</div>
<div id="postbody">
<? echo $post['body'] not sure about how to have page breaks in the db and bring them out onto the page?>
</div> and so on.
Links in the side bar would be
<a href="<?$post_pull2?>">Post Title
Oh no, I just realized, the above won't work. I need to know how to do it by id, how to find out the highest id number. My brain is fried thinking about how to do this, I hope someone can point me in the right direction, I have built up a fair bit of PHP knowledge, I don't want someone to write my code for me as I enjoy it, just offer me one or two ways that would help me achieve what I want to do, I'm sure it must be one of the most common codes ever used.
Thanks in advance.