Skip to main content
JBWebWorks
Inspiring
March 9, 2009
Answered

in PHP how to pass a recordset value through a url

  • March 9, 2009
  • 1 reply
  • 956 views
I have a blog set up with PHP/MySQL with two tables (1 table for blog entry and 1 table for comments on the blog)
I can display the blog and the comment with a LEFT JOIN recordset like this---
SELECT golf_blog.blog_ID, DATE_FORMAT( golf_blog.blog_created, '%b %e, %Y') AS blog_created, golf_blog.blog_author, golf_blog.blog_subject, golf_blog.blog_article, blog_comments.comment_article
FROM golf_blog LEFT JOIN blog_comments USING (blog_ID)
ORDER BY golf_blog.blog_created ASC

I have a link in the repeat region of this recordset going to a page with the comment insert form.
blog_ID is the primary key in the blog table and blog_ID is the index in the comment table.

How do you pass the blog_ID from the recordset to a text field in the comment insert form through the link?
Or am i even thinking about this in the right way?
This topic has been closed for replies.
Correct answer JBWebWorks
I figured it out and got it to work by passing the blog_ID as a variable on the URL link to the comment insert form page

the link is like this
<a href="golfblog_comment.php?$blog_ID=<?php echo $row_rs_golfblog['blog_ID']; ?>" >Comment</a>

and on the comment page used this code
<?php $blog_ID = '$blog_ID' ;
$blog_ID = $_GET[$blog_ID]?>

and the value of the insert field is this
<?php echo $blog_ID; ?>

I guess reading David Powers is starting to pay off. Eureka!

1 reply

DwFAQ
Participating Frequently
March 9, 2009
Heya,

Here's an idea: Put blog_ID in comment form as hidden form field.

Hope that helps!
JBWebWorks
Inspiring
March 9, 2009
thanks for your response
whether hidden field or text field is not what i am having a problem with.
i am trying to get the URL link 'comment' to pass the blog_ID to the comment page so that when the person fills in the comment form and sends the insert, it has the correct blog_ID from the blog page so i can JOIN the comment.blog_ID with the blog.blog_ID.

am i making any sense?

JBWebWorks
JBWebWorksAuthorCorrect answer
Inspiring
March 9, 2009
I figured it out and got it to work by passing the blog_ID as a variable on the URL link to the comment insert form page

the link is like this
<a href="golfblog_comment.php?$blog_ID=<?php echo $row_rs_golfblog['blog_ID']; ?>" >Comment</a>

and on the comment page used this code
<?php $blog_ID = '$blog_ID' ;
$blog_ID = $_GET[$blog_ID]?>

and the value of the insert field is this
<?php echo $blog_ID; ?>

I guess reading David Powers is starting to pay off. Eureka!