Jump to content

create select and checkbox input for PHP /Mysql table


mar92

Recommended Posts

Hello,

 

I create PHP/Mysql table that consist of 6 column.I want to make the column grade as select input of A,B,C,D to the database and i want to add select input to the Add it column .I tried several way but didn't know How ?   

 

 
<?php

         // build SELECT query
         $query = "SELECT *  FROM study";

         // Connect to MySQL
         if ( !( $database = mysql_connect( "localhost",
            "gjk", "hj" ) ) )                      
            die( "Could not connect to database </body></html>" );
   
         // open database
         if ( !mysql_select_db( "adv", $database ) )
            die( "Could not open  database </body></html>" );

         // query  database
         if ( !( $result = mysql_query( $query, $database ) ) ) 
         {
            print( "<p>Could not execute query!</p>" );
            die( mysql_error() . "</body></html>" );
         } // end if

         mysql_close( $database );
      ?><!-- end PHP script -->
      <table>
         <caption>Results of "SELECT <?php print( "$select" ) ?> 
            "</caption>
         <tr>
<th> </th>
<th>Code</th>
<th>Title</th>
<th>cr</th>
<th> prerequisite</th>
<th>Addit</th>
<th>Grade</th>


<tr>
   
   
         <?php
            // fetch each record in result set
            while ( $row = mysql_fetch_row( $result ) )
            {
               // build table to display results
               print( "<tr>" );
               
               foreach ( $row as $value ) 
                  print( "<td>$value</td>" );

               print( "</tr>" );
            } // end while
         ?><!-- end PHP script -->
      </table>
      <p>Your search yielded 
         <?php print( mysql_num_rows( $result ) ) ?> results.</p>
   </body>
</html>

Edited by mar92
Link to comment
Share on other sites

 

I want to make the column grade as select input of A,B,C,D to the database and i want to add select input to the Add it column

Your post is not very clear.

 

Are you saying  you are wanting to create a dropdown menu, containing the options A to D, for the "Add it" column in your HTML table? Then to be able to update your database with the selected values from the dropdown menus?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.