Jump to content

script for retrieving specific data from MySQL


andybrooke

Recommended Posts

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!!!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.