Getting ID from a presented table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lennart Anderson

    Getting ID from a presented table

    I'm having a MySQl table wih a lot of information. I want to present some
    main fields in a table on one page. Each record do, of course, have a unique
    ID. The presnted table will have one field as a linked field. I want to be
    able to click this link, retreive the ID information for that record and
    then present detailed data for that record on the next page.
    How do I retreive the ID?
    Any hints are very much appreciated.
    Thanks


  • Jerry Stuckle

    #2
    Re: Getting ID from a presented table

    Lennart Anderson wrote:
    I'm having a MySQl table wih a lot of information. I want to present some
    main fields in a table on one page. Each record do, of course, have a unique
    ID. The presnted table will have one field as a linked field. I want to be
    able to click this link, retreive the ID information for that record and
    then present detailed data for that record on the next page.
    How do I retreive the ID?
    Any hints are very much appreciated.
    Thanks
    >
    >
    Put the id in the link itself.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Lennart Anderson

      #3
      Re: Getting ID from a presented table


      "Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
      news:xtCdnUF-VpfLF2DYnZ2dnUV Z_rbinZ2d@comca st.com...
      Lennart Anderson wrote:
      >I'm having a MySQl table wih a lot of information. I want to present some
      >main fields in a table on one page. Each record do, of course, have a
      >unique ID. The presnted table will have one field as a linked field. I
      >want to be able to click this link, retreive the ID information for that
      >record and then present detailed data for that record on the next page.
      >How do I retreive the ID?
      >Any hints are very much appreciated.
      >Thanks
      >
      Put the id in the link itself.
      >
      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===
      I think I get the idea but I don't know how to doo that. Can you give me an
      aidea of how such a link with, I guess, embedded ID would look like?


      Comment

      • Lennart Anderson

        #4
        Re: Getting ID from a presented table


        "Lennart Anderson" <lennart.anders on@tele2.seskre v i meddelandet
        news:n%fLh.113$ Zp1.154@nntpser ver.swip.net...
        >
        "Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
        news:xtCdnUF-VpfLF2DYnZ2dnUV Z_rbinZ2d@comca st.com...
        >Lennart Anderson wrote:
        >>I'm having a MySQl table wih a lot of information. I want to present
        >>some main fields in a table on one page. Each record do, of course, have
        >>a unique ID. The presnted table will have one field as a linked field. I
        >>want to be able to click this link, retreive the ID information for that
        >>record and then present detailed data for that record on the next page.
        >>How do I retreive the ID?
        >>Any hints are very much appreciated.
        >>Thanks
        >>
        >Put the id in the link itself.
        >>
        >--
        >============== ====
        >Remove the "x" from my email address
        >Jerry Stuckle
        >JDS Computer Training Corp.
        >jstucklex@attgl obal.net
        >============== ====
        >
        I think I get the idea but I don't know how to doo that. Can you give me
        an aidea of how such a link with, I guess, embedded ID would look like?
        Furthermore, if I click a link on a displayed record I can only get
        information from the link of the last displayed record. How to get
        information of the ID from any of the earlier displayed records?


        Comment

        • Jerry Stuckle

          #5
          Re: Getting ID from a presented table

          Lennart Anderson wrote:
          "Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
          news:xtCdnUF-VpfLF2DYnZ2dnUV Z_rbinZ2d@comca st.com...
          >Lennart Anderson wrote:
          >>I'm having a MySQl table wih a lot of information. I want to present some
          >>main fields in a table on one page. Each record do, of course, have a
          >>unique ID. The presnted table will have one field as a linked field. I
          >>want to be able to click this link, retreive the ID information for that
          >>record and then present detailed data for that record on the next page.
          >>How do I retreive the ID?
          >>Any hints are very much appreciated.
          >>Thanks
          >Put the id in the link itself.
          >>
          >--
          >============== ====
          >Remove the "x" from my email address
          >Jerry Stuckle
          >JDS Computer Training Corp.
          >jstucklex@attgl obal.net
          >============== ====
          >
          I think I get the idea but I don't know how to doo that. Can you give me an
          aidea of how such a link with, I guess, embedded ID would look like?
          >
          >
          Do you know how to do it in html? Same idea - just generated with a PHP
          echo statement instead.

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • Jerry Stuckle

            #6
            Re: Getting ID from a presented table

            Lennart Anderson wrote:
            "Lennart Anderson" <lennart.anders on@tele2.seskre v i meddelandet
            news:n%fLh.113$ Zp1.154@nntpser ver.swip.net...
            >"Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
            >news:xtCdnUF-VpfLF2DYnZ2dnUV Z_rbinZ2d@comca st.com...
            >>Lennart Anderson wrote:
            >>>I'm having a MySQl table wih a lot of information. I want to present
            >>>some main fields in a table on one page. Each record do, of course, have
            >>>a unique ID. The presnted table will have one field as a linked field. I
            >>>want to be able to click this link, retreive the ID information for that
            >>>record and then present detailed data for that record on the next page.
            >>>How do I retreive the ID?
            >>>Any hints are very much appreciated.
            >>>Thanks
            >>Put the id in the link itself.
            >>>
            >>--
            >>============= =====
            >>Remove the "x" from my email address
            >>Jerry Stuckle
            >>JDS Computer Training Corp.
            >>jstucklex@attgl obal.net
            >>============= =====
            >I think I get the idea but I don't know how to doo that. Can you give me
            >an aidea of how such a link with, I guess, embedded ID would look like?
            Furthermore, if I click a link on a displayed record I can only get
            information from the link of the last displayed record. How to get
            information of the ID from any of the earlier displayed records?
            >
            >
            If you want to get information from previously displayed records you're
            going to have to save them and pass them along somehow - i.e in a
            session or hidden fields in your form.

            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            • Lennart Anderson

              #7
              Re: Getting ID from a presented table


              "Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
              news:ybqdnXJcAf ixAmDYnZ2dnUVZ_ vPinZ2d@comcast .com...
              Lennart Anderson wrote:
              >"Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
              >news:xtCdnUF-VpfLF2DYnZ2dnUV Z_rbinZ2d@comca st.com...
              >>Lennart Anderson wrote:
              >>>I'm having a MySQl table wih a lot of information. I want to present
              >>>some main fields in a table on one page. Each record do, of course,
              >>>have a unique ID. The presnted table will have one field as a linked
              >>>field. I want to be able to click this link, retreive the ID
              >>>informatio n for that record and then present detailed data for that
              >>>record on the next page.
              >>>How do I retreive the ID?
              >>>Any hints are very much appreciated.
              >>>Thanks
              >>Put the id in the link itself.
              >>>
              >>--
              >>============= =====
              >>Remove the "x" from my email address
              >>Jerry Stuckle
              >>JDS Computer Training Corp.
              >>jstucklex@attgl obal.net
              >>============= =====
              >>
              >I think I get the idea but I don't know how to doo that. Can you give me
              >an aidea of how such a link with, I guess, embedded ID would look like?
              >
              Do you know how to do it in html? Same idea - just generated with a PHP
              echo statement instead.
              >
              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===
              No, I do not know how to do that in HTML.
              But, once again, the problem is that I have a number of records presented in
              a table. All records do have unique ID. When preseneted by the hTML page
              they are parsed into "hard-coded" HTML and although I can have a field to
              act as a link I can't get the ID for the special record I am selecting. Only
              the ID for the last presented record will come through since that ID is
              still present in the array. Any hint of how to get the ID from any selected
              record?


              Comment

              • Jerry Stuckle

                #8
                Re: Getting ID from a presented table

                Lennart Anderson wrote:
                "Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                news:ybqdnXJcAf ixAmDYnZ2dnUVZ_ vPinZ2d@comcast .com...
                >Lennart Anderson wrote:
                >>"Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                >>news:xtCdnU F-VpfLF2DYnZ2dnUV Z_rbinZ2d@comca st.com...
                >>>Lennart Anderson wrote:
                >>>>I'm having a MySQl table wih a lot of information. I want to present
                >>>>some main fields in a table on one page. Each record do, of course,
                >>>>have a unique ID. The presnted table will have one field as a linked
                >>>>field. I want to be able to click this link, retreive the ID
                >>>>informati on for that record and then present detailed data for that
                >>>>record on the next page.
                >>>>How do I retreive the ID?
                >>>>Any hints are very much appreciated.
                >>>>Thanks
                >>>Put the id in the link itself.
                >>>>
                >>>--
                >>>============ ======
                >>>Remove the "x" from my email address
                >>>Jerry Stuckle
                >>>JDS Computer Training Corp.
                >>>jstucklex@attgl obal.net
                >>>============ ======
                >>I think I get the idea but I don't know how to doo that. Can you give me
                >>an aidea of how such a link with, I guess, embedded ID would look like?
                >Do you know how to do it in html? Same idea - just generated with a PHP
                >echo statement instead.
                >>
                >--
                >============== ====
                >Remove the "x" from my email address
                >Jerry Stuckle
                >JDS Computer Training Corp.
                >jstucklex@attgl obal.net
                >============== ====
                >
                No, I do not know how to do that in HTML.
                But, once again, the problem is that I have a number of records presented in
                a table. All records do have unique ID. When preseneted by the hTML page
                they are parsed into "hard-coded" HTML and although I can have a field to
                act as a link I can't get the ID for the special record I am selecting. Only
                the ID for the last presented record will come through since that ID is
                still present in the array. Any hint of how to get the ID from any selected
                record?
                >
                >
                OK, posting the code you're using would help a lot.

                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstucklex@attgl obal.net
                =============== ===

                Comment

                • Lennart Anderson

                  #9
                  Re: Getting ID from a presented table


                  "Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                  news:0oGdneT-v7svMmPYnZ2dnUV Z_s3inZ2d@comca st.com...
                  Lennart Anderson wrote:
                  >"Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                  >news:ybqdnXJcA fixAmDYnZ2dnUVZ _vPinZ2d@comcas t.com...
                  >>Lennart Anderson wrote:
                  >>>"Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                  >>>news:xtCdn UF-VpfLF2DYnZ2dnUV Z_rbinZ2d@comca st.com...
                  >>>>Lennart Anderson wrote:
                  >>>>>I'm having a MySQl table wih a lot of information. I want to present
                  >>>>>some main fields in a table on one page. Each record do, of course,
                  >>>>>have a unique ID. The presnted table will have one field as a linked
                  >>>>>field. I want to be able to click this link, retreive the ID
                  >>>>>informatio n for that record and then present detailed data for that
                  >>>>>record on the next page.
                  >>>>>How do I retreive the ID?
                  >>>>>Any hints are very much appreciated.
                  >>>>>Thanks
                  >>>>Put the id in the link itself.
                  >>>>>
                  >>>>--
                  >>>>=========== =======
                  >>>>Remove the "x" from my email address
                  >>>>Jerry Stuckle
                  >>>>JDS Computer Training Corp.
                  >>>>jstucklex@attgl obal.net
                  >>>>=========== =======
                  >>>I think I get the idea but I don't know how to doo that. Can you give
                  >>>me an aidea of how such a link with, I guess, embedded ID would look
                  >>>like?
                  >>Do you know how to do it in html? Same idea - just generated with a PHP
                  >>echo statement instead.
                  >>>
                  >>--
                  >>============= =====
                  >>Remove the "x" from my email address
                  >>Jerry Stuckle
                  >>JDS Computer Training Corp.
                  >>jstucklex@attgl obal.net
                  >>============= =====
                  >>
                  >No, I do not know how to do that in HTML.
                  >But, once again, the problem is that I have a number of records presented
                  >in a table. All records do have unique ID. When preseneted by the hTML
                  >page they are parsed into "hard-coded" HTML and although I can have a
                  >field to act as a link I can't get the ID for the special record I am
                  >selecting. Only the ID for the last presented record will come through
                  >since that ID is still present in the array. Any hint of how to get the
                  >ID from any selected record?
                  >
                  OK, posting the code you're using would help a lot.
                  >
                  --
                  =============== ===
                  Remove the "x" from my email address
                  Jerry Stuckle
                  JDS Computer Training Corp.
                  jstucklex@attgl obal.net
                  =============== ===
                  Here is the essential part of the code with the presneted table where one of
                  the records field will be a link. I want to retreive the ID for any selefted
                  record from, say, 25 presented.

                  mysql_select_db ('db2') or die ('Unable to select database!');
                  // create and execute query
                  $query = "SELECT ID, DATE_FORMAT(add ate, '%m-%d') AS adday,
                  DATE_FORMAT(add ate, '%H:%i')as adtime, addate, adnamn, adcat,
                  adheader,adtext ,adprice,adcats .catname FROM ads, adcats where ads.adcat =
                  adcats.catid order by ID DESC";
                  $result = mysql_query($qu ery)
                  or die ('Error in query: $query. ' . mysql_error());
                  // check if records were returned
                  if (mysql_num_rows ($result) 0)
                  {
                  // iterate over record set
                  // print each field

                  echo '<h2>Test on data retrieval from the data base</h2></br>';
                  echo '<table border=0 cellpadding=2 width = 100% bgcolor="#FFFF9 9"
                  bordercolor="#F FFFFF">';
                  echo '<tr>
                  <td>Ad-No.</td>
                  <td>Day</td>
                  <td>Time</td>
                  <td>Ad-header</td>
                  <td>Price CI$</td>
                  <td>Category</td>

                  </tr>';

                  while($row = mysql_fetch_obj ect($result))

                  {
                  echo '<tr>';
                  echo '<td width=5% bgcolor="#FFFFF F" align = "right">' . ($row->ID) .
                  '</td>';
                  echo '<td width=4% bgcolor="#FFFFF F">' . ($row->adday) . '</td>';
                  echo '<td width=5% bgcolor="#FFFFF F">' . ($row->adtime) . '</td>';
                  echo '<td width=40% bgcolor="#FFFFF F">' . '<a href= "advertinfo.php " >' .
                  ($row->adheader) . '</td>';
                  echo '<td width = 6% bgcolor="#FFFFF F" align = "right">' . ($row->adprice) .
                  '</td>';
                  echo '<td width = 18% bgcolor="#FFFFF F">' . ($row->catname) . '</td>';
                  echo '</tr>';


                  }

                  echo '</table>';

                  }
                  else
                  {
                  // print error message
                  echo 'No rows found!';
                  }


                  Comment

                  • Jerry Stuckle

                    #10
                    Re: Getting ID from a presented table

                    Lennart Anderson wrote:
                    "Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                    news:0oGdneT-v7svMmPYnZ2dnUV Z_s3inZ2d@comca st.com...
                    >Lennart Anderson wrote:
                    >>"Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                    >>news:ybqdnXJc AfixAmDYnZ2dnUV Z_vPinZ2d@comca st.com...
                    >>>Lennart Anderson wrote:
                    >>>>"Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                    >>>>news:xtCdnU F-VpfLF2DYnZ2dnUV Z_rbinZ2d@comca st.com...
                    >>>>>Lennart Anderson wrote:
                    >>>>>>I'm having a MySQl table wih a lot of information. I want to present
                    >>>>>>some main fields in a table on one page. Each record do, of course,
                    >>>>>>have a unique ID. The presnted table will have one field as a linked
                    >>>>>>field. I want to be able to click this link, retreive the ID
                    >>>>>>informati on for that record and then present detailed data for that
                    >>>>>>record on the next page.
                    >>>>>>How do I retreive the ID?
                    >>>>>>Any hints are very much appreciated.
                    >>>>>>Thanks
                    >>>>>Put the id in the link itself.
                    >>>>>>
                    >>>>>--
                    >>>>>========== ========
                    >>>>>Remove the "x" from my email address
                    >>>>>Jerry Stuckle
                    >>>>>JDS Computer Training Corp.
                    >>>>>jstucklex@attgl obal.net
                    >>>>>========== ========
                    >>>>I think I get the idea but I don't know how to doo that. Can you give
                    >>>>me an aidea of how such a link with, I guess, embedded ID would look
                    >>>>like?
                    >>>Do you know how to do it in html? Same idea - just generated with a PHP
                    >>>echo statement instead.
                    >>>>
                    >>>--
                    >>>============ ======
                    >>>Remove the "x" from my email address
                    >>>Jerry Stuckle
                    >>>JDS Computer Training Corp.
                    >>>jstucklex@attgl obal.net
                    >>>============ ======
                    >>No, I do not know how to do that in HTML.
                    >>But, once again, the problem is that I have a number of records presented
                    >>in a table. All records do have unique ID. When preseneted by the hTML
                    >>page they are parsed into "hard-coded" HTML and although I can have a
                    >>field to act as a link I can't get the ID for the special record I am
                    >>selecting. Only the ID for the last presented record will come through
                    >>since that ID is still present in the array. Any hint of how to get the
                    >>ID from any selected record?
                    >OK, posting the code you're using would help a lot.
                    >>
                    >--
                    >============== ====
                    >Remove the "x" from my email address
                    >Jerry Stuckle
                    >JDS Computer Training Corp.
                    >jstucklex@attgl obal.net
                    >============== ====
                    >
                    Here is the essential part of the code with the presneted table where one of
                    the records field will be a link. I want to retreive the ID for any selefted
                    record from, say, 25 presented.
                    >
                    mysql_select_db ('db2') or die ('Unable to select database!');
                    // create and execute query
                    $query = "SELECT ID, DATE_FORMAT(add ate, '%m-%d') AS adday,
                    DATE_FORMAT(add ate, '%H:%i')as adtime, addate, adnamn, adcat,
                    adheader,adtext ,adprice,adcats .catname FROM ads, adcats where ads.adcat =
                    adcats.catid order by ID DESC";
                    $result = mysql_query($qu ery)
                    or die ('Error in query: $query. ' . mysql_error());
                    // check if records were returned
                    if (mysql_num_rows ($result) 0)
                    {
                    // iterate over record set
                    // print each field
                    >
                    echo '<h2>Test on data retrieval from the data base</h2></br>';
                    echo '<table border=0 cellpadding=2 width = 100% bgcolor="#FFFF9 9"
                    bordercolor="#F FFFFF">';
                    echo '<tr>
                    <td>Ad-No.</td>
                    <td>Day</td>
                    <td>Time</td>
                    <td>Ad-header</td>
                    <td>Price CI$</td>
                    <td>Category</td>
                    >
                    </tr>';
                    >
                    while($row = mysql_fetch_obj ect($result))
                    >
                    {
                    echo '<tr>';
                    echo '<td width=5% bgcolor="#FFFFF F" align = "right">' . ($row->ID) .
                    '</td>';
                    echo '<td width=4% bgcolor="#FFFFF F">' . ($row->adday) . '</td>';
                    echo '<td width=5% bgcolor="#FFFFF F">' . ($row->adtime) . '</td>';
                    echo '<td width=40% bgcolor="#FFFFF F">' . '<a href= "advertinfo.php " >' .
                    ($row->adheader) . '</td>';
                    echo '<td width = 6% bgcolor="#FFFFF F" align = "right">' . ($row->adprice) .
                    '</td>';
                    echo '<td width = 18% bgcolor="#FFFFF F">' . ($row->catname) . '</td>';
                    echo '</tr>';
                    >
                    >
                    }
                    >
                    echo '</table>';
                    >
                    }
                    else
                    {
                    // print error message
                    echo 'No rows found!';
                    }
                    >
                    >
                    OK, if you're going to make it a link, you have to pass the id as a
                    parameter in the link, i.e.

                    echo '<td width=40% bgcolor="#FFFFF F">' . '<a href= "advertinfo.php ?id='
                    .. $row['id'] . " >' . ($row->adheader) . '</td>';

                    This will pass the link as "advertinfo.php ?id=3", for example.

                    Then in advertinfo.php you use access it with $_GET['id'].

                    Be sure to use isset($_GET['id']) in case someone comes to this page
                    without an id being passed.



                    --
                    =============== ===
                    Remove the "x" from my email address
                    Jerry Stuckle
                    JDS Computer Training Corp.
                    jstucklex@attgl obal.net
                    =============== ===

                    Comment

                    • Lennart Anderson

                      #11
                      Re: Getting ID from a presented table


                      "Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                      news:wvSdnUTGP7 22TWPYnZ2dnUVZ_ rylnZ2d@comcast .com...
                      Lennart Anderson wrote:
                      >"Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                      >news:0oGdneT-v7svMmPYnZ2dnUV Z_s3inZ2d@comca st.com...
                      >>Lennart Anderson wrote:
                      >>>"Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                      >>>news:ybqdnXJ cAfixAmDYnZ2dnU VZ_vPinZ2d@comc ast.com...
                      >>>>Lennart Anderson wrote:
                      >>>>>"Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                      >>>>>news:xtCdn UF-VpfLF2DYnZ2dnUV Z_rbinZ2d@comca st.com...
                      >>>>>>Lennart Anderson wrote:
                      >>>>>>>I'm having a MySQl table wih a lot of information. I want to
                      >>>>>>>presen t some main fields in a table on one page. Each record do, of
                      >>>>>>>course , have a unique ID. The presnted table will have one field as
                      >>>>>>>a linked field. I want to be able to click this link, retreive the
                      >>>>>>>ID information for that record and then present detailed data for
                      >>>>>>>that record on the next page.
                      >>>>>>>How do I retreive the ID?
                      >>>>>>>Any hints are very much appreciated.
                      >>>>>>>Thanks
                      >>>>>>Put the id in the link itself.
                      >>>>>>>
                      >>>>>>--
                      >>>>>>========= =========
                      >>>>>>Remove the "x" from my email address
                      >>>>>>Jerry Stuckle
                      >>>>>>JDS Computer Training Corp.
                      >>>>>>jstucklex@attgl obal.net
                      >>>>>>========= =========
                      >>>>>I think I get the idea but I don't know how to doo that. Can you give
                      >>>>>me an aidea of how such a link with, I guess, embedded ID would look
                      >>>>>like?
                      >>>>Do you know how to do it in html? Same idea - just generated with a
                      >>>>PHP echo statement instead.
                      >>>>>
                      >>>>--
                      >>>>=========== =======
                      >>>>Remove the "x" from my email address
                      >>>>Jerry Stuckle
                      >>>>JDS Computer Training Corp.
                      >>>>jstucklex@attgl obal.net
                      >>>>=========== =======
                      >>>No, I do not know how to do that in HTML.
                      >>>But, once again, the problem is that I have a number of records
                      >>>presented in a table. All records do have unique ID. When preseneted by
                      >>>the hTML page they are parsed into "hard-coded" HTML and although I can
                      >>>have a field to act as a link I can't get the ID for the special record
                      >>>I am selecting. Only the ID for the last presented record will come
                      >>>through since that ID is still present in the array. Any hint of how to
                      >>>get the ID from any selected record?
                      >>OK, posting the code you're using would help a lot.
                      >>>
                      >>--
                      >>============= =====
                      >>Remove the "x" from my email address
                      >>Jerry Stuckle
                      >>JDS Computer Training Corp.
                      >>jstucklex@attgl obal.net
                      >>============= =====
                      >>
                      >Here is the essential part of the code with the presneted table where one
                      >of the records field will be a link. I want to retreive the ID for any
                      >selefted record from, say, 25 presented.
                      >>
                      >mysql_select_d b('db2') or die ('Unable to select database!');
                      >// create and execute query
                      >$query = "SELECT ID, DATE_FORMAT(add ate, '%m-%d') AS adday,
                      >DATE_FORMAT(ad date, '%H:%i')as adtime, addate, adnamn, adcat,
                      >adheader,adtex t,adprice,adcat s.catname FROM ads, adcats where ads.adcat =
                      >adcats.catid order by ID DESC";
                      >$result = mysql_query($qu ery)
                      >or die ('Error in query: $query. ' . mysql_error());
                      >// check if records were returned
                      >if (mysql_num_rows ($result) 0)
                      >{
                      >// iterate over record set
                      >// print each field
                      >>
                      >echo '<h2>Test on data retrieval from the data base</h2></br>';
                      >echo '<table border=0 cellpadding=2 width = 100% bgcolor="#FFFF9 9"
                      >bordercolor="# FFFFFF">';
                      >echo '<tr>
                      ><td>Ad-No.</td>
                      ><td>Day</td>
                      ><td>Time</td>
                      ><td>Ad-header</td>
                      ><td>Price CI$</td>
                      ><td>Category </td>
                      >>
                      ></tr>';
                      >>
                      >while($row = mysql_fetch_obj ect($result))
                      >>
                      >{
                      >echo '<tr>';
                      >echo '<td width=5% bgcolor="#FFFFF F" align = "right">' . ($row->ID) .
                      >'</td>';
                      >echo '<td width=4% bgcolor="#FFFFF F">' . ($row->adday) . '</td>';
                      >echo '<td width=5% bgcolor="#FFFFF F">' . ($row->adtime) . '</td>';
                      >echo '<td width=40% bgcolor="#FFFFF F">' . '<a href= "advertinfo.php " >' .
                      >($row->adheader) . '</td>';
                      >echo '<td width = 6% bgcolor="#FFFFF F" align = "right">' .
                      >($row->adprice) . '</td>';
                      >echo '<td width = 18% bgcolor="#FFFFF F">' . ($row->catname) . '</td>';
                      >echo '</tr>';
                      >>
                      >>
                      >}
                      >>
                      >echo '</table>';
                      >>
                      >}
                      >else
                      >{
                      >// print error message
                      >echo 'No rows found!';
                      >}
                      >>
                      >>
                      >
                      OK, if you're going to make it a link, you have to pass the id as a
                      parameter in the link, i.e.
                      >
                      echo '<td width=40% bgcolor="#FFFFF F">' . '<a href= "advertinfo.php ?id=' .
                      $row['id'] . " >' . ($row->adheader) . '</td>';
                      >
                      This will pass the link as "advertinfo.php ?id=3", for example.
                      >
                      Then in advertinfo.php you use access it with $_GET['id'].
                      >
                      Be sure to use isset($_GET['id']) in case someone comes to this page
                      without an id being passed.
                      >
                      >
                      >
                      --
                      =============== ===
                      Remove the "x" from my email address
                      Jerry Stuckle
                      JDS Computer Training Corp.
                      Thanks. This seems most promising but don't I need to have some kind of
                      form method to pass the $_GET variable. Just now the table is presented
                      without any kind of form tags.
                      jstucklex@attgl obal.net
                      =============== ===

                      Comment

                      • Jerry Stuckle

                        #12
                        Re: Getting ID from a presented table

                        Lennart Anderson wrote:
                        "Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                        news:wvSdnUTGP7 22TWPYnZ2dnUVZ_ rylnZ2d@comcast .com...
                        >Lennart Anderson wrote:
                        >>"Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                        >>news:0oGdne T-v7svMmPYnZ2dnUV Z_s3inZ2d@comca st.com...
                        >>>Lennart Anderson wrote:
                        >>>>"Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                        >>>>news:ybqdnX JcAfixAmDYnZ2dn UVZ_vPinZ2d@com cast.com...
                        >>>>>Lennart Anderson wrote:
                        >>>>>>"Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                        >>>>>>news:xtCd nUF-VpfLF2DYnZ2dnUV Z_rbinZ2d@comca st.com...
                        >>>>>>>Lennar t Anderson wrote:
                        >>>>>>>>I'm having a MySQl table wih a lot of information. I want to
                        >>>>>>>>prese nt some main fields in a table on one page. Each record do, of
                        >>>>>>>>cours e, have a unique ID. The presnted table will have one field as
                        >>>>>>>>a linked field. I want to be able to click this link, retreive the
                        >>>>>>>>ID information for that record and then present detailed data for
                        >>>>>>>>that record on the next page.
                        >>>>>>>>How do I retreive the ID?
                        >>>>>>>>Any hints are very much appreciated.
                        >>>>>>>>Thank s
                        >>>>>>>Put the id in the link itself.
                        >>>>>>>>
                        >>>>>>>--
                        >>>>>>>======== ==========
                        >>>>>>>Remove the "x" from my email address
                        >>>>>>>Jerry Stuckle
                        >>>>>>>JDS Computer Training Corp.
                        >>>>>>>jstucklex@attgl obal.net
                        >>>>>>>======== ==========
                        >>>>>>I think I get the idea but I don't know how to doo that. Can you give
                        >>>>>>me an aidea of how such a link with, I guess, embedded ID would look
                        >>>>>>like?
                        >>>>>Do you know how to do it in html? Same idea - just generated with a
                        >>>>>PHP echo statement instead.
                        >>>>>>
                        >>>>>--
                        >>>>>========== ========
                        >>>>>Remove the "x" from my email address
                        >>>>>Jerry Stuckle
                        >>>>>JDS Computer Training Corp.
                        >>>>>jstucklex@attgl obal.net
                        >>>>>========== ========
                        >>>>No, I do not know how to do that in HTML.
                        >>>>But, once again, the problem is that I have a number of records
                        >>>>presented in a table. All records do have unique ID. When preseneted by
                        >>>>the hTML page they are parsed into "hard-coded" HTML and although I can
                        >>>>have a field to act as a link I can't get the ID for the special record
                        >>>>I am selecting. Only the ID for the last presented record will come
                        >>>>through since that ID is still present in the array. Any hint of how to
                        >>>>get the ID from any selected record?
                        >>>OK, posting the code you're using would help a lot.
                        >>>>
                        >>>--
                        >>>============ ======
                        >>>Remove the "x" from my email address
                        >>>Jerry Stuckle
                        >>>JDS Computer Training Corp.
                        >>>jstucklex@attgl obal.net
                        >>>============ ======
                        >>Here is the essential part of the code with the presneted table where one
                        >>of the records field will be a link. I want to retreive the ID for any
                        >>selefted record from, say, 25 presented.
                        >>>
                        >>mysql_select_ db('db2') or die ('Unable to select database!');
                        >>// create and execute query
                        >>$query = "SELECT ID, DATE_FORMAT(add ate, '%m-%d') AS adday,
                        >>DATE_FORMAT(a ddate, '%H:%i')as adtime, addate, adnamn, adcat,
                        >>adheader,adte xt,adprice,adca ts.catname FROM ads, adcats where ads.adcat =
                        >>adcats.cati d order by ID DESC";
                        >>$result = mysql_query($qu ery)
                        >>or die ('Error in query: $query. ' . mysql_error());
                        >>// check if records were returned
                        >>if (mysql_num_rows ($result) 0)
                        >>{
                        >>// iterate over record set
                        >>// print each field
                        >>>
                        >>echo '<h2>Test on data retrieval from the data base</h2></br>';
                        >>echo '<table border=0 cellpadding=2 width = 100% bgcolor="#FFFF9 9"
                        >>bordercolor=" #FFFFFF">';
                        >>echo '<tr>
                        >><td>Ad-No.</td>
                        >><td>Day</td>
                        >><td>Time</td>
                        >><td>Ad-header</td>
                        >><td>Price CI$</td>
                        >><td>Categor y</td>
                        >>>
                        >></tr>';
                        >>>
                        >>while($row = mysql_fetch_obj ect($result))
                        >>>
                        >>{
                        >>echo '<tr>';
                        >>echo '<td width=5% bgcolor="#FFFFF F" align = "right">' . ($row->ID) .
                        >>'</td>';
                        >>echo '<td width=4% bgcolor="#FFFFF F">' . ($row->adday) . '</td>';
                        >>echo '<td width=5% bgcolor="#FFFFF F">' . ($row->adtime) . '</td>';
                        >>echo '<td width=40% bgcolor="#FFFFF F">' . '<a href= "advertinfo.php " >' .
                        >>($row->adheader) . '</td>';
                        >>echo '<td width = 6% bgcolor="#FFFFF F" align = "right">' .
                        >>($row->adprice) . '</td>';
                        >>echo '<td width = 18% bgcolor="#FFFFF F">' . ($row->catname) . '</td>';
                        >>echo '</tr>';
                        >>>
                        >>>
                        >>}
                        >>>
                        >>echo '</table>';
                        >>>
                        >>}
                        >>else
                        >>{
                        >>// print error message
                        >>echo 'No rows found!';
                        >>}
                        >>>
                        >>>
                        >OK, if you're going to make it a link, you have to pass the id as a
                        >parameter in the link, i.e.
                        >>
                        >echo '<td width=40% bgcolor="#FFFFF F">' . '<a href= "advertinfo.php ?id=' .
                        >$row['id'] . " >' . ($row->adheader) . '</td>';
                        >>
                        >This will pass the link as "advertinfo.php ?id=3", for example.
                        >>
                        >Then in advertinfo.php you use access it with $_GET['id'].
                        >>
                        >Be sure to use isset($_GET['id']) in case someone comes to this page
                        >without an id being passed.
                        >>
                        >>
                        >>
                        >--
                        >============== ====
                        >Remove the "x" from my email address
                        >Jerry Stuckle
                        >JDS Computer Training Corp.
                        >
                        Thanks. This seems most promising but don't I need to have some kind of
                        form method to pass the $_GET variable. Just now the table is presented
                        without any kind of form tags.
                        >jstucklex@attgl obal.net
                        >============== ====
                        >
                        >
                        You need a form to pass values via POST. But GET values can be passed
                        in the href. Check alt.html for more info on this.

                        --
                        =============== ===
                        Remove the "x" from my email address
                        Jerry Stuckle
                        JDS Computer Training Corp.
                        jstucklex@attgl obal.net
                        =============== ===

                        Comment

                        • Lennart Anderson

                          #13
                          Re: Getting ID from a presented table


                          "Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                          news:ye6dnfGwJs nek2LYnZ2dnUVZ_ sDinZ2d@comcast .com...
                          Lennart Anderson wrote:
                          >"Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                          >news:wvSdnUTGP 722TWPYnZ2dnUVZ _rylnZ2d@comcas t.com...
                          >>Lennart Anderson wrote:
                          >>>"Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                          >>>news:0oGdn eT-v7svMmPYnZ2dnUV Z_s3inZ2d@comca st.com...
                          >>>>Lennart Anderson wrote:
                          >>>>>"Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                          >>>>>news:ybqdn XJcAfixAmDYnZ2d nUVZ_vPinZ2d@co mcast.com...
                          >>>>>>Lennart Anderson wrote:
                          >>>>>>>"Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                          >>>>>>>news:xtC dnUF-VpfLF2DYnZ2dnUV Z_rbinZ2d@comca st.com...
                          >>>>>>>>Lenna rt Anderson wrote:
                          >>>>>>>>>I'm having a MySQl table wih a lot of information. I want to
                          >>>>>>>>>presen t some main fields in a table on one page. Each record do,
                          >>>>>>>>>of course, have a unique ID. The presnted table will have one
                          >>>>>>>>>fiel d as a linked field. I want to be able to click this link,
                          >>>>>>>>>retrei ve the ID information for that record and then present
                          >>>>>>>>>detail ed data for that record on the next page.
                          >>>>>>>>>How do I retreive the ID?
                          >>>>>>>>>Any hints are very much appreciated.
                          >>>>>>>>>Than ks
                          >>>>>>>>Put the id in the link itself.
                          >>>>>>>>>
                          >>>>>>>>--
                          >>>>>>>>======= ===========
                          >>>>>>>>Remov e the "x" from my email address
                          >>>>>>>>Jerry Stuckle
                          >>>>>>>>JDS Computer Training Corp.
                          >>>>>>>>jstucklex@attgl obal.net
                          >>>>>>>>======= ===========
                          >>>>>>>I think I get the idea but I don't know how to doo that. Can you
                          >>>>>>>give me an aidea of how such a link with, I guess, embedded ID
                          >>>>>>>would look like?
                          >>>>>>Do you know how to do it in html? Same idea - just generated with a
                          >>>>>>PHP echo statement instead.
                          >>>>>>>
                          >>>>>>--
                          >>>>>>========= =========
                          >>>>>>Remove the "x" from my email address
                          >>>>>>Jerry Stuckle
                          >>>>>>JDS Computer Training Corp.
                          >>>>>>jstucklex@attgl obal.net
                          >>>>>>========= =========
                          >>>>>No, I do not know how to do that in HTML.
                          >>>>>But, once again, the problem is that I have a number of records
                          >>>>>presente d in a table. All records do have unique ID. When preseneted
                          >>>>>by the hTML page they are parsed into "hard-coded" HTML and although
                          >>>>>I can have a field to act as a link I can't get the ID for the
                          >>>>>special record I am selecting. Only the ID for the last presented
                          >>>>>record will come through since that ID is still present in the array.
                          >>>>>Any hint of how to get the ID from any selected record?
                          >>>>OK, posting the code you're using would help a lot.
                          >>>>>
                          >>>>--
                          >>>>=========== =======
                          >>>>Remove the "x" from my email address
                          >>>>Jerry Stuckle
                          >>>>JDS Computer Training Corp.
                          >>>>jstucklex@attgl obal.net
                          >>>>=========== =======
                          >>>Here is the essential part of the code with the presneted table where
                          >>>one of the records field will be a link. I want to retreive the ID for
                          >>>any selefted record from, say, 25 presented.
                          >>>>
                          >>>mysql_select _db('db2') or die ('Unable to select database!');
                          >>>// create and execute query
                          >>>$query = "SELECT ID, DATE_FORMAT(add ate, '%m-%d') AS adday,
                          >>>DATE_FORMAT( addate, '%H:%i')as adtime, addate, adnamn, adcat,
                          >>>adheader,adt ext,adprice,adc ats.catname FROM ads, adcats where ads.adcat
                          >>>= adcats.catid order by ID DESC";
                          >>>$result = mysql_query($qu ery)
                          >>>or die ('Error in query: $query. ' . mysql_error());
                          >>>// check if records were returned
                          >>>if (mysql_num_rows ($result) 0)
                          >>>{
                          >>>// iterate over record set
                          >>>// print each field
                          >>>>
                          >>>echo '<h2>Test on data retrieval from the data base</h2></br>';
                          >>>echo '<table border=0 cellpadding=2 width = 100% bgcolor="#FFFF9 9"
                          >>>bordercolor= "#FFFFFF">' ;
                          >>>echo '<tr>
                          >>><td>Ad-No.</td>
                          >>><td>Day</td>
                          >>><td>Time</td>
                          >>><td>Ad-header</td>
                          >>><td>Price CI$</td>
                          >>><td>Category </td>
                          >>>>
                          >>></tr>';
                          >>>>
                          >>>while($row = mysql_fetch_obj ect($result))
                          >>>>
                          >>>{
                          >>>echo '<tr>';
                          >>>echo '<td width=5% bgcolor="#FFFFF F" align = "right">' . ($row->ID) .
                          >>>'</td>';
                          >>>echo '<td width=4% bgcolor="#FFFFF F">' . ($row->adday) . '</td>';
                          >>>echo '<td width=5% bgcolor="#FFFFF F">' . ($row->adtime) . '</td>';
                          >>>echo '<td width=40% bgcolor="#FFFFF F">' . '<a href= "advertinfo.php " >'
                          >>>. ($row->adheader) . '</td>';
                          >>>echo '<td width = 6% bgcolor="#FFFFF F" align = "right">' .
                          >>>($row->adprice) . '</td>';
                          >>>echo '<td width = 18% bgcolor="#FFFFF F">' . ($row->catname) . '</td>';
                          >>>echo '</tr>';
                          >>>>
                          >>>>
                          >>>}
                          >>>>
                          >>>echo '</table>';
                          >>>>
                          >>>}
                          >>>else
                          >>>{
                          >>>// print error message
                          >>>echo 'No rows found!';
                          >>>}
                          >>>>
                          >>>>
                          >>OK, if you're going to make it a link, you have to pass the id as a
                          >>parameter in the link, i.e.
                          >>>
                          >>echo '<td width=40% bgcolor="#FFFFF F">' . '<a href= "advertinfo.php ?id='
                          >>. $row['id'] . " >' . ($row->adheader) . '</td>';
                          >>>
                          >>This will pass the link as "advertinfo.php ?id=3", for example.
                          >>>
                          >>Then in advertinfo.php you use access it with $_GET['id'].
                          >>>
                          >>Be sure to use isset($_GET['id']) in case someone comes to this page
                          >>without an id being passed.
                          >>>
                          >>>
                          >>>
                          >>--
                          >>============= =====
                          >>Remove the "x" from my email address
                          >>Jerry Stuckle
                          >>JDS Computer Training Corp.
                          >>
                          >Thanks. This seems most promising but don't I need to have some kind of
                          >form method to pass the $_GET variable. Just now the table is presented
                          >without any kind of form tags.
                          >>jstucklex@attgl obal.net
                          >>============= =====
                          >>
                          >>
                          >
                          You need a form to pass values via POST. But GET values can be passed in
                          the href. Check alt.html for more info on this.
                          >
                          --
                          =============== ===
                          Remove the "x" from my email address
                          Jerry Stuckle
                          JDS Computer Training Corp.
                          jstucklex@attgl obal.net
                          =============== ===
                          No way I can get this to work. The only way I can get the link to reat is by
                          using:
                          '<a href= "advertinfo.php ?id=$row->ID" >' . ($row->adheader).
                          But then the id is not parsed in the right way o by looking at th HTML-code
                          in the browser View source the link is still: <a href=
                          "advertinfo.php ?id=$row->ID" >. When I click and use the $_GET on the linked
                          page I just get: $row->ID as the answer.
                          HOw do I get the link to interprete the ID-number and to use that as the
                          link-parameter.
                          I admit that I am not too experienced in php but have the intention to learn
                          but this thing is going to drive me more crazy than usual.


                          Comment

                          Working...