can i make one value to many option ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sheau Wei
    New Member
    • Sep 2006
    • 34

    can i make one value to many option ?

    1. let say my table in MySQL have a column call NUMBER. In this column it would be value 1,2,3. Now i want to make the 1,2,3 as option to user to choose.
    what the code should be?

    2. is it this code is right?
    <Select NAME="field2">
    <Option VALUE='NUMBER'> 1</Option>
    <Option VALUE='NUMBER>2 </Option>
    </Select>
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    If you want to populate these fields from the database, you have to do that differently. But basically, the code you presented should be (for 3 numbers)
    (the value= is passed to your form, the value between > and < is displayed to the user).
    [HTML]
    <Select NAME="field2">
    <Option VALUE='1'>Numbe r 1</Option>
    <Option VALUE='2'>Numbe r 2</Option>
    <Option VALUE='3'>Numbe r 3</Option>
    </Select>[/HTML]

    Ronald :cool:

    Comment

    • Sheau Wei
      New Member
      • Sep 2006
      • 34

      #3
      Originally posted by ronverdonk
      If you want to populate these fields from the database, you have to do that differently. But basically, the code you presented should be (for 3 numbers)
      (the value= is passed to your form, the value between > and < is displayed to the user).
      [HTML]
      <Select NAME="field2">
      <Option VALUE='1'>Numbe r 1</Option>
      <Option VALUE='2'>Numbe r 2</Option>
      <Option VALUE='3'>Numbe r 3</Option>
      </Select>[/HTML]

      Ronald :cool:
      thank you for your reply. now i have another question is that i had generate the hyperlink as the code last time i get from this forum.


      while($result = mysql_fetch_arr ay( $data ))
      {

      echo "<tr><td><a href='Informati onPage.php?id={ $result['ID']}'>{$result['ID']}</a></td>
      <td>{$result['Name']}</td>
      <td>{$result['Brand']}</td>
      </tr>";

      i want the user click to the ID and then it will go to another page and display the information corresponding to the ID. I am sucess to make the hyperlink.But i dont know the coding to display the information to user when user click to the ID hyperlink.Can u help me?Thank you

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        You lost me now. Does this last question have to do with:

        1. usage of the select (drop-down) list as discussed in his thread, where you want a dynamic link in the drop down box?
        2. another (previous) thread you posted and got an answer see how to generate hyperlink for entire number column of number ID ....
        3. this is an entirely new question

        Please reply.

        Ronald :cool:

        Comment

        • Sheau Wei
          New Member
          • Sep 2006
          • 34

          #5
          Originally posted by ronverdonk
          You lost me now. Does this last question have to do with:

          1. usage of the select (drop-down) list as discussed in his thread, where you want a dynamic link in the drop down box?
          2. another (previous) thread you posted and got an answer see how to generate hyperlink for entire number column of number ID ....
          3. this is an entirely new question

          Please reply.

          Ronald :cool:
          1.no.this does not do with the select list as discussess in this thread
          2.this is about the queastion how to generate hyperlink for entire number of ID.

          Comment

          • Sheau Wei
            New Member
            • Sep 2006
            • 34

            #6
            Originally posted by ronverdonk
            You already have a number of data fields in the table from which you can click. What fields do you want to display on the new page? And do you pass these values from the 'clickable link' ID page to the new page or do you want to pass the ID to the new page and read more data from the MySql database to display at the new page?

            Ronald :cool:
            the field i want to displa in new page is DateReceive, Quantity, Price, Status and Location. I wan to pass the ID to new page and read more data from MySql database to display at new page.

            Comment

            • ronverdonk
              Recognized Expert Specialist
              • Jul 2006
              • 4259

              #7
              You already have a number of data fields in the table from which you can click. What fields do you want to display on the new page? And do you pass these values from the 'clickable link' ID page to the new page or do you want to pass the ID to the new page and read more data from the MySql database to display at the new page?

              To speed up this discussion I will assume the latter. So your calling table was generated like this:
              [php]echo "<tr><td><a href='AnotherPa ge.php?id={$res ult['ID']}'>{$result['ID']}</a></td>
              <td>{$result['NamaPeralatan']}</td>
              <td>{$result['Motor']}</td>
              <td>{$result['Operasi']}</td>
              </tr>";
              [/php]

              The AnotherPage.php looks like this:
              [php]
              <?php
              // check if id is passed to this routine
              if (isset($_GET['id']) {
              // if yes: remove harmful tags and save the passed id in variable $id
              $id = strip_tags($_GE T['id']);
              // now you can do your MySql functions (sample)
              // connect to server .....
              // connect to data base .....

              // construct SQL statement
              $sql = "SELECT field1, field2, ... from table_name WHERE ID='$id'";
              // execute the select
              }
              else { // id not passed to this function
              echo "Id was not passed to this routine";
              die;
              }
              [/php]

              Ronald :cool:

              Comment

              • Sheau Wei
                New Member
                • Sep 2006
                • 34

                #8
                Originally posted by ronverdonk
                You already have a number of data fields in the table from which you can click. What fields do you want to display on the new page? And do you pass these values from the 'clickable link' ID page to the new page or do you want to pass the ID to the new page and read more data from the MySql database to display at the new page?

                To speed up this discussion I will assume the latter. So your calling table was generated like this:
                [php]echo "<tr><td><a href='AnotherPa ge.php?id={$res ult['ID']}'>{$result['ID']}</a></td>
                <td>{$result['NamaPeralatan']}</td>
                <td>{$result['Motor']}</td>
                <td>{$result['Operasi']}</td>
                </tr>";
                [/php]

                The AnotherPage.php looks like this:
                [php]
                <?php
                // check if id is passed to this routine
                if (isset($_GET['id']) {
                // if yes: remove harmful tags and save the passed id in variable $id
                $id = strip_tags($_GE T['id']);
                // now you can do your MySql functions (sample)
                // connect to server .....
                // connect to data base .....

                // construct SQL statement
                $sql = "SELECT field1, field2, ... from table_name WHERE ID='$id'";
                // execute the select
                }
                else { // id not passed to this function
                echo "Id was not passed to this routine";
                die;
                }
                [/php]

                Ronald :cool:
                i had try following your step but still the parse error at line
                $id = strip_tags($_GE T['id']);
                the parse error mention that it was unexpected T_VARIABLE .

                Comment

                • Sheau Wei
                  New Member
                  • Sep 2006
                  • 34

                  #9
                  Originally posted by Sheau Wei
                  i had try following your step but still the parse error at line
                  $id = strip_tags($_GE T['id']);
                  the parse error mention that it was unexpected T_VARIABLE .
                  i am very sorry Ronald. Juz now i make some mistaken in typing and causee error. Now i can can run it already . I think i cant success in my program without ur help. thank you very much .

                  Comment

                  • Sheau Wei
                    New Member
                    • Sep 2006
                    • 34

                    #10
                    Originally posted by Sheau Wei
                    i am very sorry Ronald. Juz now i make some mistaken in typing and causee error. Now i can can run it already . I think i cant success in my program without ur help. thank you very much .
                    After following your instruction i had sucess reach what i want to create. now i have another new question is that if i have display a table , how can i create an edit button to edit the content in the table ? Let say below was my table .


                    $information=my sql_fetch_array ($sql);
                    echo "<table border='1'>";
                    echo "<tr><td Name</th><td >Brand</th></tr>";

                    echo"<tr><td>{$ information1['Name']}</td>
                    <td>{$informati on1['Brand']}</td>;
                    echo "</table>";

                    Comment

                    • ronverdonk
                      Recognized Expert Specialist
                      • Jul 2006
                      • 4259

                      #11
                      I hope you do not mean that you want to edit the ENTIRE table. Usually people want to edit just the information in ONE ROW of a table.
                      Is that (ONE ROW edit) your request?

                      Ronald :cool:

                      Comment

                      • Sheau Wei
                        New Member
                        • Sep 2006
                        • 34

                        #12
                        Originally posted by ronverdonk
                        I hope you do not mean that you want to edit the ENTIRE table. Usually people want to edit just the information in ONE ROW of a table.
                        Is that (ONE ROW edit) your request?

                        Ronald :cool:
                        yes.i oly want to edit one row of a table. How to make it?

                        Comment

                        • ronverdonk
                          Recognized Expert Specialist
                          • Jul 2006
                          • 4259

                          #13
                          Originally posted by Sheau Wei
                          After following your instruction i had sucess reach what i want to create. now i have another new question is that if i have display a table , how can i create an edit button to edit the content in the table ? Let say below was my table .

                          $information=my sql_fetch_array ($sql);
                          echo "<table border='1'>";
                          echo "<tr><td Name</th><td >Brand</th></tr>";
                          echo"<tr><td>{$ information1['Name']}</td>
                          <td>{$informati on1['Brand']}</td>;
                          echo "</table>";
                          The sample answer to your last question requires approx 60 lines code.
                          Since this goes far beyond the request in your original thread and to allow other members of this forum to view and participate in my upcoming reply, I advise you to start a new thread with a title such as: how to dynamically edit table entries or something like that.
                          When you have started that thread I will submit my response and code.

                          Ronald :cool:

                          Comment

                          Working...