Jump to content

Archived

This topic is now archived and is closed to further replies.

dmarchman

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.

Share this post


Link to post
Share on other sites

×

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.