phpuserlogin Posted June 1, 2023 Share Posted June 1, 2023 <?php # Set page title and display header section. $page_title = 'database' ; include ( 'includes/header.html' ) ; # Open database connection. require ( 'connect_db.php' ) ; $q = "SELECT * FROM forum" ; $r = mysqli_query( $dbc, $q ) ; if ( mysqli_num_rows( $r ) > 0 ) { echo '<table><tr><th>Posted By</th><th>Subject</th><th id="msg">Message</th></tr>'; while ( $row = mysqli_fetch_array( $r, MYSQLI_ASSOC )) { echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. $row['post_date'].'</td> <td>' . $row['subject'] . '</td><td>' . $row['message'] . '</td> </tr>'; } echo '</table>' ; } else { echo '<p>There are currently no messages.</p>' ; } # Close database connection. mysqli_close( $dbc ) ; # Display footer section. include ( 'includes/footer.html' ) ; ?> I would like to select one row list of the following. As this old example displays a bunch of rows, so a drop down menu would individual select one item from the sql. Can I do that with this example, is it complicated to do so? Link to comment Share on other sites More sharing options...
phpuserlogin Posted June 23, 2023 Author Share Posted June 23, 2023 (edited) $q = "SELECT * FROM forum" ; $r = mysqli_query( $dbc, $q ) ; if ( mysqli_num_rows( $r ) > 0 ) { echo '<table><tr><th>Posted By</th><th>Subject</th><th id="msg">Message</th></tr>'; while ( $row = mysqli_fetch_array( $r, MYSQLI_ASSOC )) { echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. $row['post_date'].'</td> <td>' . $row['subject'] . '</td><td>' . $row['message'] . '</td> </tr>'; } echo '</table>' ; } So row Posted by, do I make a link in order to select that column, or use a drop down. to select a specific row for the data. Posted by is just an example. Record data 1, a very basic example is just what I'm trying to tinker with, with this code. Subject and so on. Edited June 23, 2023 by phpuserlogin Link to comment Share on other sites More sharing options...
phpuserlogin Posted June 23, 2023 Author Share Posted June 23, 2023 <?php # Set page title and display header section. $page_title = 'database' ; include ( 'includes/header.html' ) ; # Open database connection. require ( 'connect_db.php' ) ; # Display body section, retrieving from 'forum' database table. $q = "SELECT * FROM forum" ; $r = mysqli_query( $dbc, $q ) ; if ( mysqli_num_rows( $r ) > 0 ) { echo '<table><tr><th>Posted By</th><th>Subject</th>'; while ( $row = mysqli_fetch_array( $r, MYSQLI_ASSOC )) { echo '<tr><td> <td>' . $row['subject'] . '</td><td>' . '</td> </tr>'; } echo '</table>' ; } else { echo '<p>There are currently no messages.</p>' ; } # Close database connection. mysqli_close( $dbc ) ; # Display footer section. include ( 'includes/footer.html' ) ; ?> Link to comment Share on other sites More sharing options...
phpuserlogin Posted August 18, 2023 Author Share Posted August 18, 2023 <?php # Set page title and display header section. $page_title = 'database' ; include ( 'includes/header.html' ) ; # Open database connection. require ( 'connect_db.php' ) ; # Display body section, retrieving from 'forum' database table. $q = "SELECT * FROM forum" ; $r = mysqli_query( $dbc, $q ) ; if ( mysqli_num_rows( $r ) > 0 ) { echo '<table>'; while ( $row = mysqli_fetch_array( $r, MYSQLI_ASSOC )) { echo ' <td>' . $row['subject'] . '</td> </tr>'; } echo '</table>' ; } else { echo '<p>There are currently no messages.</p>' ; } # Close database connection. mysqli_close( $dbc ) ; # Display footer section. include ( 'includes/footer.html' ) ; ?> I've updated it, so it just displays the words in the subject row from the sql. So Playstation 2 model no would be selected from the actual subject row, via link, and a drop down menu would be the select method. I've solved the display of the data. How do I create a link to select subject row or what ever. Link to comment Share on other sites More sharing options...
phpuserlogin Posted August 22, 2023 Author Share Posted August 22, 2023 It isn't the link, it is the drop down menu. https://www.w3schools.com/css/css_dropdowns.asp I was thinking of the old drop downs before Html 5.😐 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now