rohan_m Posted May 21, 2011 Share Posted May 21, 2011 I would like to read data from a MYSQL database, but would only like to display the data that has a specific column value. Look at what I have in my table: http://i51.tinypic.com/vio6me.png I would like user 1 to only see the member_id value of 1 rows, member 2 seeing only 2, etc. My current code displays all of the data for every user. Here is my current code: <?php // Connects to your Database mysql_connect("mysql11.000webhost.com", "a7196206_data", "1994love") or die(mysql_error()); mysql_select_db("a7196206_data") or die(mysql_error()); $data = mysql_query("SELECT * FROM Teachers") or die(mysql_error()); Print "<table border cellpadding=3 width=750px>"; while($info = mysql_fetch_array( $data )) { Print "</table>"; Print "<br />"; Print "<table border cellpadding=3 width=750px>"; Print "<tr>"; Print "<th width=150px>Teacher Name:</th> <td>".$info['Teacher'] . "</td></tr> "; Print "<tr>"; Print "<th width=150px>Homework Page:</th> <td>".$info['Homework'] . " </td></tr>"; Print "<tr>"; Print "<th width=150px>Subject:</th> <td>".$info['Subject'] . "</td></tr> "; } Print "</table>"; ?> If someone could lead me in the right direction as to how this could be accomplished, I would appreciate it very much. Thanks! Link to comment https://forums.phpfreaks.com/topic/237074-retrieving-data-from-mysql-table-help/ Share on other sites More sharing options...
eMonk Posted May 21, 2011 Share Posted May 21, 2011 You can use: SELECT * FROM Teachers WHERE member_id = 1 SELECT * FROM Teachers WHERE member_id = 2 etc... Link to comment https://forums.phpfreaks.com/topic/237074-retrieving-data-from-mysql-table-help/#findComment-1218534 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.