Profile Last View By...

Started on the old forum in March 2008 · view the original in the archive · old links redirect here

45 replies · 3,892 views · started 18 years ago · 1 min read

TL;DR · summary of 45 replies
  • The code to show the last 10 profile viewers was not working as expected.
  • A solution was proposed by rukiya, but it resulted in a syntax error on line 2434 of index.php for some users.
  • Another user provided an alternative approach using three fields: id, uid, and who. However, this did not work for everyone due to different database configurations or issues with the SQL query structure.
  • The thread concluded that showing the last 10 profile viewers required creating a new table specifically for tracking these views, which was deemed necessary by some users.

Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.

16 participants
alexism Developer · 136 posts #1

firstly..i want to say that i hv search but didnt found..so dont ask me to search..2ndly..anybody have that code share wit me plz.. External image (may be gone)

crazybrumi Super moderator Principal · 1,064 posts #3

that shows it

 $sqlthing = mysql_query("SELECT * FROM last WHERE username='$name'");
 $dt=(mysql_result($sqlthing,0,"date"));
   $by=(mysql_result($sqlthing,0,"who"));
//echo "
Profile Last Viewed At
$dt";
echo "
Profile Last Viewed By: $by
";

this updates it

sql2 = "UPDATE last SET who='$username' WHERE username='$name'";
$result2 = mysql_query($sql2);

$dt = date('Y-m-d H:i:s');
$sql = "SELECT * FROM last where username='$name'";
$result = mysql_query($sql);
$number_of_rows = mysql_num_rows($result);
if ($number_of_rows=="1")
{
$sql = "UPDATE last SET date='$dt' WHERE username='$name'";
$result = mysql_query($sql);

}
if ($number_of_rows=="0")
{

$dt = date('Y-m-d H:i:s');

$sql11 = "INSERT INTO last (username,date,who) VALUES
('$name','$dt','$username')";
$result11 = mysql_query($sql11);
}

hope this works for you but it will need slite alteration to your specific script

Want something coded email me at sales@webnwaphost.com for a prices.

http://flagcounter.com/more/W80q

alexism Developer · 136 posts #4

///////////index.php (viewuser)

 $sqlthing = mysql_query("SELECT * FROM last WHERE username='$name'");
 $dt=(mysql_result($sqlthing,0,"date"));
   $by=(mysql_result($sqlthing,0,"who"));
//echo "
Profile Last Viewed At
$dt";
echo "
Profile Last Viewed By: $by
";

//////////where must iput this code?

sql2 = "UPDATE last SET who='$username' WHERE username='$name'";
$result2 = mysql_query($sql2);
$dt = date('Y-m-d H:i:s');
$sql = "SELECT * FROM last where username='$name'";
$result = mysql_query($sql);
$number_of_rows = mysql_num_rows($result);
if ($number_of_rows=="1")
{
$sql = "UPDATE last SET date='$dt' WHERE username='$name'";
$result = mysql_query($sql);
}
if ($number_of_rows=="0")
{

$dt = date('Y-m-d H:i:s');

$sql11 = "INSERT INTO last (username,date,who) VALUES
('$name','$dt','$username')";
$result11 = mysql_query($sql11);
}
mcKeny Developer · 130 posts #6

thats too long mate this is how i do mine

$wid = $_GET["wid"];

$me = userid_sesid($sesid);

$update = mysql_query("INSERT INTO mc_users SET last_view='".$me."' WHERE id='".$wid."'"));  
//fetch last view
$lv = mysql_fetch_array(mysql_query("SELECT last_view FROM mc_users WHERE id='".$wid."'"));

echo "Last viewed by: ".nick_userid($lb[0]);

External image (may be gone)

R.M.C

PHP Adovocate B)

alexism Developer · 136 posts #7

wut is the sql table for bcfc n mckeny coding?

crazybrumi Super moderator Principal · 1,064 posts #8

wut is the sql table for bcfc n mckeny coding?

-- --------------------------------------------------------

-- 
-- Table structure for table `last`
-- 

CREATE TABLE `last` (
  `username` varchar(30) NOT NULL default '',
  `date` varchar(50) NOT NULL default '0000-00-00',
  `who` varchar(30) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- 
-- Dumping data for table `last`
-- 

-- --------------------------------------------------------

Want something coded email me at sales@webnwaphost.com for a prices.

http://flagcounter.com/more/W80q

crazybrumi Super moderator Principal · 1,064 posts #9

thats too long mate this is how i do mine

$wid = $_GET["wid"];

$me = userid_sesid($sesid);
$update = mysql_query("INSERT INTO mc_users SET last_view='".$me."' WHERE id='".$wid."'"));  
//fetch last view
$lv = mysql_fetch_array(mysql_query("SELECT last_view FROM mc_users WHERE id='".$wid."'"));

echo "Last viewed by: ".nick_userid($lb[0]);

External image (may be gone)

if your using lavalair its best for yu 2 use the code mckeny gave ya as its been coded for it wer as my code came from my script

Want something coded email me at sales@webnwaphost.com for a prices.

http://flagcounter.com/more/W80q

rukiya Lead · 569 posts #11

wat about a list of the last 10 users who view ur profile?

am gonna code it....External image (may be gone)

too easy add these two new fields in ibwf_users

lastview int(100) NOT NULL default '0'
ltime int(100) NOT NULL default '0'

in index.php under $action=="viewuser"

$lv= getuid_sid($sid);
$tm = time();
mysql_query("INSERT INTO ibwf_users SET lastview='".$lv."',ltime='".$tm."' WHERE uid='".$who."'")); 
$sql = (mysql_query("SELECT lastview,ltime FROM ibwf_users WHERE uid='".$who."' ORDER BY ltime DESC LIMIT 10"));
while($row = mysql_fetch_array($sql)){
echo "Last viewed by: ".getnick_uid($row[0]);
$newtime =$row[1]+(6 *60 *60); 
echo ".date("D d M y - H:i:s",$newtime).
";
        echo "------------
";

}
mcKeny Developer · 130 posts #13

if thats for the last ten viewer that definitely wouldn't work you would have to create a complete new table... if its regarding alexim question thats still too long check how short mine is...

R.M.C

PHP Adovocate B)

mazalo Developer · 50 posts #14
mysql_query("INSERT INTO ibwf_users SET lastview='".$lv."',ltime='".$tm."' WHERE uid='".$who."'"));

Here is error!Look Parse error: syntax error, unexpected ')' in /home2/lidijama/public_html/proba/index.php on line 2434

GumSlone Administrator Principal · 1,690 posts #15
mysql_query("INSERT INTO ibwf_users SET lastview='".$lv."',ltime='".$tm."' WHERE uid='".$who."'"));

Here is error!Look Parse error: syntax error, unexpected ')' in /home2/lidijama/public_html/proba/index.php on line 2434

Ha ha, External image (may be gone) this shall work:

mysql_query("INSERT INTO ibwf_users SET lastview='".$lv."',ltime='".$tm."' WHERE uid='".$who."'");

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

rukiya Lead · 569 posts #17

thats too long mate this is how i do mine

$wid = $_GET["wid"];

$me = userid_sesid($sesid);
$update = mysql_query("INSERT INTO mc_users SET last_view='".$me."' WHERE id='".$wid."'"));  
//fetch last view
$lv = mysql_fetch_array(mysql_query("SELECT last_view FROM mc_users WHERE id='".$wid."'"));

echo "Last viewed by: ".nick_userid($lb[0]);

External image (may be gone)

$update = mysql_query("INSERT INTO mc_users SET last_view='".$me."' WHERE id='".$wid."'"));

A WHERE clause cannot be used in INSERT SQL command so

this is how i do mine is 100% false

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close