SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Oct 2012
    Location
    Hove, East Sussex, UK
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Open an HTML web-page by selecting a MySQL table row using php

    I am a "seasoned" MS Access developer now managing web-sites as well; I have searched far and wide but can not find an exact [or near] match to my puzzle.

    I have a MySQL database on a web-host that feeds table data into a php web-page; the page displays a table of x40 Groups in multiple columns per row. I also have a drop-down box filter that allows users to select rows based upon a column cell that lists the day of the week that each Group takes place. Now, to enhance it, I need to allow users to select a Group table row and have the html page open for that Group, either in place of the php page "_top", or in a new tab "_blank" [no preference].

    In .NET with SQLServer, I can have the table web-page open with a "Select" link on each row, and clicking that "Select" option opens the appropriate page based upon the content of a cell in that row. I need to do the same [or similar] in php.

    Can this be done in php? If so, can anyone supply sample code or clues?

    Many thanks in advance.
    Dave B.

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    66 Post(s)
    Tagged
    2 Thread(s)
    Sample data please :-) I'm also a little confused on your definition of "Group". Do you mean a group of rows, or do you mean a "Group" that is a column within the table structure?

    But just break the task down to it's simplest form and then use PHP to fill in your variable. Where are you getting the group from? What is the url you will be forwarding them to?

  3. #3
    SitePoint Member
    Join Date
    Oct 2012
    Location
    Hove, East Sussex, UK
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your prompt reply. Sorry for the confusion - the "Group" is a table column header and these are mutual-interest groups of people, as in Gardens Group, Social Group, Play Reading Group, etc. I need to put a row-selector in each row [perhaps even using the cell with Group name] that will open the web-page for that row. So click on the selector for the Gardens Group row and the URL ../../Gardens.html would open.

    How do I add a selector to each row in php and how can I have the appropriate page open?
    Would the code be in a separate page or in the same php page?

    Regards
    Dave B.

  4. #4
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    66 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by dibby44 View Post
    Thanks for your prompt reply. Sorry for the confusion - the "Group" is a table column header and these are mutual-interest groups of people, as in Gardens Group, Social Group, Play Reading Group, etc. I need to put a row-selector in each row [perhaps even using the cell with Group name] that will open the web-page for that row. So click on the selector for the Gardens Group row and the URL ../../Gardens.html would open.

    How do I add a selector to each row in php and how can I have the appropriate page open?
    Would the code be in a separate page or in the same php page?

    Regards
    Dave B.
    You'll need to pull up the area that produces the rows based on your recordset. You'll see that the result is returned to an array and there will be a foreach loop to show all the records. Within that loop you'll want to find a nice cozy place to put something along the lines of this :

    PHP Code:
    echo '<a href = "../../' $array['Group'] . '.html">' $array['Group'] . '</a>'
    While looping through it will use the current rows "Group" to populate your line.

  5. #5
    SitePoint Member
    Join Date
    Oct 2012
    Location
    Hove, East Sussex, UK
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks - I'll have a play and let you know how I get on
    Regards
    Dave B.

  6. #6
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,169
    Mentioned
    153 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dibby44 View Post
    Many thanks - I'll have a play and let you know how I get on
    Regards
    Dave B.
    If you get stuck, post the code you have (minus any database connections, we will assume you did that right ) and we'll take a look at it.


Bookmarks

Posting Permissions

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