www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 21

Thread: generate links

  1. #1
    Join Date
    Mar 2003
    Posts
    191

    generate links

    with my php script, it retrieves customer complaint information from a database and lists them on screen. The information it retrieves are like customer records, about 8 fields in total, such as name, date, error reported etc.

    Does anyone know how to show just a few fields or a short description, with a link to open the full description in a new window?

    ta

  2. #2
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    I'd make two PHP pages. The first lists the complaints in the short form that you desire, and the second will display everything. Then, what you will need to do is link to the second page with a query string attached, and this will tell the page which record to show.

  3. #3
    Join Date
    Mar 2003
    Posts
    191
    that sounds a bit complicated - know of any tutorials on the subject?

  4. #4
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Hmm... not really. None on that exact subject. It really shouldn't be that hard, as long as you know how to get the records out of the database. On the first page, you will want to display everything that is in the database, with the exception of the complaint (or perhaps just a few words of the complaint). Then, on the second page, you will want to show all the fields for the one specific complain, including the full text of the complaint.

  5. #5
    Join Date
    Mar 2003
    Posts
    191
    i've made the first page display a summary of fields, along with a link to a second page, that can display all the fields and information.

    Problem is, how do i pass the id of the item the user clicked on from the first page to the second - as in how can i tell the second page what item to retrieve?

  6. #6
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    When you are writing the links in with PHP, just include them in the <a href> something like this:

    <a href="yourpage.php?id=$var">text</a>

    and then to get that value on yourpage.php, you can use $_GET["id"];

  7. #7
    Join Date
    Mar 2003
    Posts
    191
    i've put the value in the link tag like you said, but i'm not sure if its not working from the link or at the second page.

    heres some of my code:

    this is on the first page, that displays the summaries:

    $index = $row ["complaintID"];

    echo "<a href = detailed.php?id = $index>" . $row ["problemSummary"] . "</a>";


    When i click on the link, it send the index as part of the url for the detailed.php page.

    in the detailed.php page, i simply have ( to check its recieving the $index):

    echo "Your Complaint ID is: " . $_GET["index"];

    but its not retriveing the $index - where am i going wrong?

  8. #8
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    echo "Your Complaint ID is: " . $_GET["index"];
    should be
    echo "Your Complaint ID is: " . $_GET["id"];
    as we assigned the GET variable "id" to equal the value of $index.

  9. #9
    Join Date
    Mar 2003
    Posts
    191
    i seeeeeeeeeeeeeee..........yep thats working great now.

    Thanks for your help today pyro


  10. #10
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    You are very welcome...

  11. #11
    Join Date
    Mar 2003
    Posts
    191
    sorry to bring up another old post, but i don't want to start a new one on the subject, when all the info is above.

    Theres two sections to the site, a private section and a global section. In these sections, customer complaints are displayed in tables. In the private secton, the content is specific to the login name, and in the global section, the content is all the complaints from all users.

    Using the above code:
    $index = $row ["complaintID"];

    echo "<a href = detailed.php?id = $index>" . $row ["problemSummary"] . "</a>";

    Then on detailed.php, to retreive and display the complete complaint form:

    $result = mysql_query("select * from complaints where complaintnumber = ' $_GET[id]' ")

    I've just been told that in the private section, the complaintnumber is unique, but in the public section, there may be more than one of the same complaintnumber.

    Using this script works fine for the private section, but when in the public section, it will retreive and display two or more complaints if they have the same id.

    by adding into the mysql statement:
    AND customerid = $Name
    will only then retreive the complaint of the name the user logged in as, therefore defeating the point of having a global complaints section.

    I've also tried LIMIT 1, but it only retreives the first one it finds.


    Is there any way around this?

  12. #12
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    I'm not sure what it is that you need to try to do...

  13. #13
    Join Date
    Mar 2003
    Posts
    191
    ok, say theres the personal section:

    xxx's complaint's:
    ---------------------------
    id|description|status |
    ---------------------------
    5|description|complete|
    7|description|complete|
    9|description|complete|
    ---------------------------

    this is displayed on the page as a table. "Description"'s are links, that will open up in a new window the full details of that entry.

    Now if they are in the global section, there may be entries with the same id:

    all companies complaints:
    ----------------------------
    id|description|status |
    ----------------------------
    4|description|complete |
    8|description|complete |
    5|description|complete |
    5|description|complete |
    4|description|complete |
    ----------------------------

    as this section is made up of entries from more than one client.

    Now the code for the detail.php page, to display the full description of the complaint uses the id as one of the conditions in the sql lookup:

    select * from complaints where complaintnumber = $_GET['id']

    So now, if the user clicks on id 5, the detail page will open, with two entries in it - both the id5 entries.

    I need this detail page to open only the entry clicked on, but am boggled on how to do so.

    thanks for your time anyhow pyro



  14. #14
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    You are going to need to either use some sort of unique ID (which is what I would recommend) or also match by something other than just the id...

  15. #15
    Join Date
    Mar 2003
    Posts
    191
    i was just this second thinking -
    how about a check, that if the id's are the same, then it matches, say the first 10 characters of the description - i think this would work, but not sure how.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles