Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

in PHP how to pass a recordset value through a url

Participant ,
Mar 09, 2009 Mar 09, 2009
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?
TOPICS
Server side applications
967
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Mar 09, 2009 Mar 09, 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!
Translate
Advisor ,
Mar 09, 2009 Mar 09, 2009
Heya,

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

Hope that helps!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 09, 2009 Mar 09, 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 09, 2009 Mar 09, 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!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 09, 2009 Mar 09, 2009
LATEST
JBWebWorks wrote:
> I guess reading David Powers is starting to pay off. Eureka!

:-)

--
David Powers
Adobe Community Expert, Dreamweaver
http://foundationphp.com
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines