andybrooke Posted January 28, 2008 Share Posted January 28, 2008 Hi. I am not sure if this falls under MySQL or PHP help so i have posted this in both! I have created a script that looks up a table on my phpMySQL database and displays the whole table. I am Trying to create an online tracker and need to add in code to filter the information to only display the data from the table that is relevent to whome ever is logged in. the script for what i have done so far is: <?php $database="db231930750"; mysql_connect ("**************", "***********", "**********"); @mysql_select_db($database) or die( "Unable to select database"); $result = mysql_query( "SELECT Userid, ClientName, DateOfAction, Action, Status FROM OnlineTracker" ) or die("SELECT Error: ".mysql_error()); $num_rows = mysql_num_rows($result); print "There are $num_rows records.<P>"; print "<table width=900 border=1>\n"; while ($get_info = mysql_fetch_row($result)){ print "<tr>\n"; foreach ($get_info as $field) print "\t<td><font face=arial size=1/>$field</font></td>\n"; print "</tr>\n"; } print "</table>\n"; ?> When someone logs in it sets the session : if ( isset($_SESSION['User']) ) the relevent field to filter in the table is "UserId" i.e. only show fields that the "UserId" equals the session User. 1st would i do this in mysql database or write script in php and add to the script above. if so what would the script be. thanks!!! Quote Link to comment https://forums.phpfreaks.com/topic/88165-filtering-my-data-to-display-specific-info-from-a-table/ 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.