mrherman Posted January 22, 2010 Share Posted January 22, 2010 I'm in over my head as a PHP learner. I have a simple HTML table display of data that results from an MySQL query. I would like to have a "modify" indicator button and a "delete" indicator button for each row, so that the user can choose to modify the contents for a particular row or rows. I am asking for some suggestion as to where I might go looking for information on how to make this interactivity possible, as I'm sure this is not a "quick-answer" type of question. Thanks! Link to comment https://forums.phpfreaks.com/topic/189456-radio-button-showing-in-an-html-table-resulting-from-mysql-query/ Share on other sites More sharing options...
fareedreg Posted January 22, 2010 Share Posted January 22, 2010 Provide code ... otherwise no one can help u out.. Link to comment https://forums.phpfreaks.com/topic/189456-radio-button-showing-in-an-html-table-resulting-from-mysql-query/#findComment-1000032 Share on other sites More sharing options...
mrherman Posted January 22, 2010 Author Share Posted January 22, 2010 Here is the code from my "browse.php" page. Sorry about all the commenting... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Data Browse - Edit - Export</title> </head> <body> <div id="wrap"> <?php session_start () ; ?> <!-- ---- ---- ---- ---- ---- HEADER --> <div id="header"> <h1>Data Browse - Edit - Export</h1> </div> <!-- ---- ---- ---- ---- ---- CENTER CONTENT --> <div id="browsedata"> <?php $host = 'localhost'; $root = 'root'; $db_pass = 'mypass'; $db = 'proj_sap'; $tb_users = 'sap_users'; $tb_data = 't_tims0809' ; $schcode = "320" . $_SESSION [ 'school_code' ] ; #---------------------------------------------------------------\ #- Connect to db. #---------------------------------------------------------------/ if ( ! mysql_connect ( $host, $root, $db_pass ) ) { exit ( "Can't connect to database" ) ; } if ( ! mysql_select_db ( $db ) ) { die ( "Can't select database" ) ; } #---------------------------------------------------------------\ #- SQL #---------------------------------------------------------------/ $sql = " SELECT last_name AS lastname , first_name AS firstname , grade AS gr , ethnic AS eth , sex AS sex , dob AS dob , reason AS reas , mon_init AS month FROM {$tb_data} WHERE tag <> '' AND NOT ISNULL(tag) AND schcode = {$schcode} " ; $result = mysql_query ( $sql ) ; if ( ! $result ) { die ( "Query to show fields from table failed" ) ; } else { #---------------------------------------------------------------\ #- Get number of fields for use in html table. #---------------------------------------------------------------/ $fields_num = mysql_num_fields ( $result ) ; } #---------------------------------------------------------------\ #- Set up table. #- 1. Title #- 2. Set up table format. #- 3. Start the row. #- 3. For each field, establish a table cell within the row. #- 4 end the row #---------------------------------------------------------------/ /* *************************************************************\ * mysql_fetch_field ( resource:$result [, int $field_offset = 0 ] ) * Get column information from a result and return as an object * * result: The result resource that is being evaluated. * This result comes from a call to mysql_query(). * * field_offset: This is the numerical field offset. If the * field offset is not specified, the next field that was not * yet retrieved by this function is retrieved. The field_offset * starts at 0. * * The properties of the object are: * * name - column name * table - name of the table the column belongs to * def - default value of the column * max_length - maximum length of the column * not_null - 1 if the column cannot be NULL * primary_key - 1 if the column is a primary key * unique_key - 1 if the column is a unique key * multiple_key - 1 if the column is a non-unique key * numeric - 1 if the column is numeric * blob - 1 if the column is a BLOB * type - the type of the column * unsigned - 1 if the column is unsigned * zerofill - 1 if the column is zero-filled * ***************************************************************/ echo "<h2>School: " . $schcode . "</h2>" ; echo "<h2>Category: " . "current students" . "</h2>" ; echo "<hr>" ; echo "<table border = '1' cellpadding = '1' cellspacing = '1'>" ; echo "<tr>" ; #---------------------------------------------------------------\ #- Header row: loop to go through each field to get field names. #---------------------------------------------------------------/ for ( $i = 0 ; $i < $fields_num ; $i++ ) { $field = mysql_fetch_field ( $result ) ; #---------------------------------------------------------------\ #- Get each field name and print each in its own cell. #---------------------------------------------------------------/ echo "<td> {$field->name} </td>" ; } echo "</tr>\n"; // while there are still rows to be had... // start a table row... // for each array element referred to as "cell"... while ( $row = mysql_fetch_row ( $result ) ) { echo "<tr>"; // for each array element referred to as "cell"... foreach ( $row as $cell ) { // start a cell, drop in the value, end the cell... echo "<td> $cell </td>"; } // finally, end the row... echo "</tr>\n"; } mysql_free_result($result); ?> <!--========================== FOOTER --> <?php // include "footer.php"; ?> </div> <!--*wrap*--> </body> </html> Link to comment https://forums.phpfreaks.com/topic/189456-radio-button-showing-in-an-html-table-resulting-from-mysql-query/#findComment-1000052 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.