Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    200
    Thanks
    27
    Thanked 2 Times in 2 Posts

    passing values to query databases

    Hello,

    I'm trying to query a database using values passed from a form (user input). Usually I do this using an input box, a jump menu or something similar...using the post method to get the values.

    Is it possible to have an <li> pass a value which I can then use to query my database? What I'd really like to do is have a 'newsflash' on a home page. Each link would be a <li> list item, and would link to a specific page, e.g news.php. News.php would query the database using the value from the <li> and only output the information relevant to that headline. This way each headline links to the same page, but outputs different information!

    Does anyone know if this is possible? Or you might even have a better way of accomplishing the same thing?

    Thanks a lot!

    Nicky

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by nickyfraggle View Post
    Is it possible to have an <li> pass a value which I can then use to query my database? What I'd really like to do is have a 'newsflash' on a home page. Each link would be a <li> list item, and would link to a specific page, e.g news.php.
    Your two options here are to pass the value for the query as part of the URL on the link, or if you want to use forms then include a hidden field in each <li />.

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    200
    Thanks
    27
    Thanked 2 Times in 2 Posts
    Your two options here are to pass the value for the query as part of the URL on the link, or if you want to use forms then include a hidden field in each <li />.

    So...do you mean having something like www.mydomain.com/article.php?article=news1

    Does this automatically query my database, or would I need some other code?

    I'm not sure how the hidden field in the <li> would work. Would I automatically submit it on click?

    Thanks very much for your help. Personally I think the first method is clearer, but as I'm learning I'd like to understand how both work.

    Thanks,

    Nicky


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •