Recently Viewed record list

Hello all,

I built a record search and display for some information that we have in our database. The whole point of the search is so that our employees can quickly reference a document through the web browser. One of the upgrades that I am trying to do to it is create a section off to the right which shows the employee’s recently viewed record. So far, I am stumped, my attempts at logging ended up logging the search term, or the entire results list.

Any ideas?

Thanks for the help! I included the code below.
[php]



table { border-collapse: collapse; border: solid 1px black; } td { padding: 2px 6px; border: solid 1px black; } ' method='post'>

Account Code or Company name:

Advanced Search

<?php if(isset($_POST['search'])) { $connx = mysql_connect('localhost', '*****', '*****') or die("connx"); $db = mysql_select_db('*****_*****') or die(mysql_error()); # convert to upper case, trim it, and replace spaces with "|": $search = (ini_get('magic_quotes_gpc')) ? stripslashes($_POST['search']) : $_POST['search']; $search = mysql_real_escape_string($search); $search = strtoupper(preg_replace('/[^a-zA-Z0-9-&\s]/', ' ', trim($_POST['search']))); # create a MySQL REGEXP for the search: $regexp = "REGEXP '[[:<:]]($search)[[:alpha:]]*[[:>:]]'"; $query = "SELECT document_name, description FROM `documents` WHERE UPPER(`document_name`) $regexp OR ". "`document_name` $regexp"; $result = mysql_query($query) or die($query . " - " . mysql_error()); echo "\n"; while($row = mysql_fetch_assoc($result)) { echo ""; echo ''; echo "\n"; } } ?> [/php]

Which leads to this page to display the document.

[php]


table { border-collapse: collapse; border: solid 1px black; } td { padding: 2px 6px; border: solid 1px black; } ' method='post'>

Search for:

Back to Account Code Search

<?php if(isset($_POST['search'])) { $connx = mysql_connect('localhost', '*****', '*****') or die("connx"); $db = mysql_select_db('*****_*****') or die(mysql_error()); # convert to upper case, trim it, and replace spaces with "|": $search = (ini_get('magic_quotes_gpc')) ? stripslashes($_POST['search']) : $_POST['search']; $search = mysql_real_escape_string($search); $search = strtoupper(preg_replace('/[^a-zA-Z0-9-&\s]/', ' ', trim($_POST['search']))); # create a MySQL REGEXP for the search: $regexp = "REGEXP '[[:<:]]($search)[[:alpha:]]*[[:>:]]'"; $query = "SELECT document_name, description FROM `documents` WHERE UPPER(`description`) $regexp OR ". "`document_name` $regexp"; $result = mysql_query($query) or die($query . " - " . mysql_error());
 echo "<table>\n"; 

while($row = mysql_fetch_assoc($result))
{
echo “

”;
echo ‘’;
echo “\n”;
}
}
?> <? $hostname = "localhost"; // $username = "*****"; // $password = "*****"; // $usertable = "*****"; // $dbName = "*****_*****"; // MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable"); @mysql_select_db( "$dbName") or die( "Unable to select database"); ?> <?php if(isset($_GET['docname'])) { // Connect to MySQL // Check docname $docname = mysql_real_escape_string($_GET['docname']); $query = mysql_query("SELECT document_name, description FROM `documents` WHERE `document_name`='" . $docname . "'"); if(mysql_num_rows($query) == 1) { $doc = mysql_fetch_array($query); echo nl2br ($doc['description']); } else { echo 'Document not found!'; } } ?>[/php]
', $row['document_name'], '
’, $row[‘document_name’], ‘

Try a new database table with employee identifiers and then store a delimitated string of the PIDs of the last rows in the database they accessed. Then you can recall the string as a history listing.

let me know if you need more clarity.

Thanks for the response!

I was hoping for something a little less invasive, since this database is currently being used and manipulated by another piece of software. I have been researching ways to use cookies in the browser, but I am still coming up with nothing.

At this time we are not using a login style system for the page, so I don’t really have anything I can populate from there.

Do you think its worth chasing a cookie based solution?

No because bowsers now a days tend to clear cookies once closed. try a file based system maybe XML or CSV

Fair point. To be honest though, I am not too sure how to work with other file storage mediums outside of the sql database.

Here is a tutorial
http://www.ozzu.com/programming-forum/writing-array-data-csv-file-with-php-t65293.html

Thanks, I will start going through that right now, it’s not letting me give you karma btw.

You have to have 25 posts so dont worry about it.

Sponsor our Newsletter | Privacy Policy | Terms of Service