xmark02 Posted March 17, 2016 Share Posted March 17, 2016 (edited) Hi Guys, Need help, I'm newbie in PHP. this is my first time to create my own php. Content of Questions: 1. Displaying Data from MySQL to HTML using php * Refer Search DATA.png Can you help me how to view the tables in HTML, everytime I click search it's loading to another page and displayed the tables the thing I want to see is to view/display the table in html. hope you can help guys. THank You. search_filtering.php Edited March 17, 2016 by xmark02 Quote Link to comment https://forums.phpfreaks.com/topic/301023-display-tables-in-mysql-and-search-using-php/ Share on other sites More sharing options...
drewdan Posted March 20, 2016 Share Posted March 20, 2016 (edited) What code are you using to query your database? <?php $conn = mysqli_connect("localhost", "yourusername", "yourpassword") or die(mysqli_error($conn)); mysqli_select_db($conn, "yourdb") or die(mysqli_error($conn)); $client = $_GET['client']; $query = "select * from tablename where client='$client'"; $result = mysqli_query($conn, $query); $count = mysqli_num_rows($result); if($count==0) { echo "No Results Found"; } else { $table = '<table>'; while($array=mysqli_fetch_array($result)) { $table .= '<tr><td>' . $array['name'] . '</td><td>' . $array['otherdetail'] . '</td></tr>' } $table .= '</table>'; } echo $table; ?> or something like that anyway is what you will need to write to query a database and generate a html table to be output into the browser Edited March 20, 2016 by drewdan Quote Link to comment https://forums.phpfreaks.com/topic/301023-display-tables-in-mysql-and-search-using-php/#findComment-1532232 Share on other sites More sharing options...
ginerjm Posted March 20, 2016 Share Posted March 20, 2016 Hopefully you sanitize the GET variable before using it in your query. Basic security! Also - if you do already have code you should show us the RELEVANT area that you are having a problem. Many of us don't go to other sites to see possibly malicious pages. See the Rules. Quote Link to comment https://forums.phpfreaks.com/topic/301023-display-tables-in-mysql-and-search-using-php/#findComment-1532242 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.