I have printed questions on faq.php...
when click on that question it will go to faqview.php
In that faqview.php , i want to print my previous viewd question...

Can any one help me out...
Help is urgent...
Thanks..

Recommended Answers

All 12 Replies

Hey i tried this :

if(!empty($_GET['nid']))
{
session_unregister();
session_register();
$_SESSION['prev'].=$_GET['nid'];
$_SESSION['prev'].=",";
print_r($_SESSION['prev']);
}

I got the answer correctly..
But any other thougts with out sessions...will be appreciated..

faq.php

<a href="faqview.php?faqpk=12">FAQ Title</a>

faqview.php

<?
if(!is_numeric($_GET['faqpk']))
{
	header("location: faq.php");
	exit();
}

$faqpk = $_GET['faqpk'];
$query = "select title, description from faq where faqpk = " . $faqpk;
$result = mysql_query($query);

while ($row = mysql_fetch_assoc($result)) {
    echo "<p>".$row["title"]."</p>";
    echo "<p>".$row["description"]."</p>";
}
?>

previous viewd question

I don't understand. Can you explain further?

Thanks...
And i want to print four previously viewed questions ...
Than what should i do..

All the questions that you've viewed up to this point?

sorry for my grammitical mistakes...
I want to print four or more previously viewed questions on my faqview.php

Thanks...

ya,exactly....

Have an array, put the question numbers (or ids) you have viewed in the array. Keep the array in the session. Display last 4 questions using the last 4 indexes of the array.

Yes Nav...
I also did like that ,i got..
But i want it with out sessions...
If any thought ,Please Tel me...
Thank you...

Well, then you have to pass the array as a hidden form element. But if the user uses back button, then the chances of these values getting 'lost' is more.

I guess you could also do that in the database too. Have like an faq_activity table that updates every time a user views an faq and then you could just pull the 4 most recent for that user. You'd have to keep it cleaned up else it will get fairly large, but it could be as simple as a faq_activitypk, faqpk and userpk.

$query = "select distinct faqpk, userpk from faq_activity where userpk = " . $userpk . " order by faq_activitypk desc limit 4";

something like that.

commented: smart reply... +1

k...Thanks for your time...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.