Jump to content

Displaying recordset data


Recommended Posts

What I'm trying to do is create an entry page for my blog that will display my blog entries. To give you an example of what is going to be displayed, here is the layout:

 

Recent blog header

Most recent title

date posted

tagline

blog entry body copy

 

Previous blog entries header

Blog title

Blog title

Blog title

 

I basically want the most recent entry in my blog database to display in its entirety, then below that show the next 3 recent entries in the database as a title only. This is the query I use to display the most recent entry:

 

SELECT *

FROM blogent  INNER JOIN topics ON idtop_blogent = id_top

ORDER BY id_blogent DESC LIMIT 1

 

And with the help of a friend (who knows nothing about PHP but knows ColdFusion so I took the code he gave me and did my best to translate it) I wrote this query to try to display the other entries:

 

SELECT *

FROM blogent  INNER JOIN topics ON idtop_blogent = id_top

WHERE id_blogent <> '$query_rsBlog'

ORDER BY id_blogent DESC

 

the $query_rsBlog is the variable name the query is being stored in. it's a recordset built w/ Dreamweaver since I'm not comfortable with hand writing my SQL.

 

Here is the full code for the recordsets that Dreamweaver writes if it helps..

 

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]mysql_select_db($database_heading1, $heading1);

$query_rsBlog = \"SELECT * FROM blogent  INNER JOIN topics ON idtop_blogent = id_top ORDER BY id_blogent DESC LIMIT 1\";

$rsBlog = mysql_query($query_rsBlog, $heading1) or die(mysql_error());

$row_rsBlog = mysql_fetch_assoc($rsBlog);

$totalRows_rsBlog = mysql_num_rows($rsBlog);

 

mysql_select_db($database_heading1, $heading1);

$query_rsOtherBlogs = \"SELECT * FROM blogent  INNER JOIN topics ON idtop_blogent = id_top WHERE id_blogent <> \'$query_rsBlog\' ORDER BY id_blogent DESC\";

$rsOtherBlogs = mysql_query($query_rsOtherBlogs, $heading1) or die(mysql_error());

$row_rsOtherBlogs = mysql_fetch_assoc($rsOtherBlogs);

$totalRows_rsOtherBlogs = mysql_num_rows($rsOtherBlogs);[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

 

If anyone could educate me on this I would appreciate it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.