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
alesh Lead · 604 posts #23

to show last 10 profile viewers

wouldnt tht just fill database without any purpouse?

theres more than 1000 profile views per day at my site, so in just 10 days there will b more than 10.000 unwanted rows..........

eeeeerrr....

rukiya Lead · 569 posts #25

It can be done with minimum 3 fields@advisor pamod who has imposed on you to show 10 last profile viewers when you are thinking the mysql table and its rows are purposeless?10000rows will load 0.5mb db space.who said you to conduct a site with inadequate db space?? Use DELELE sql command mentioning the deletion time if you are anxious about your inadequete db space@alesh

mcKeny Developer · 130 posts #26

External image (may be gone) wtf? are you new to mysql or what why cant WHERE clause use in a insert query, moran? how will it know which user row to update?

R.M.C

PHP Adovocate B)

alesh Lead · 604 posts #27

It can be done with minimum 3 fields@advisor pamod who has imposed on you to show 10 last profile viewers when you are thinking the mysql table and its rows are purposeless?10000rows will load 0.5mb db space.who said you to conduct a site with inadequate db space?? Use DELELE sql command mentioning the deletion time if you are anxious about your inadequete db space@alesh

i have unlimited database dude.... unlimited bandwith.... 2 gigs of space.... and guess what?? its free...well just 4 me thou... its nice 2 have a friend with own host lol...

i just said earlier tht its useles 2 have 10.000 useles rows if the same r nt in use....

its almoust the same if u delete a post at forum, but it stays in database..... 4 what? its useles right?

eeeeerrr....

rukiya Lead · 569 posts #28

External image (may be gone) wtf? are you new to mysql or what why cant WHERE clause use in a insert query, moran? how will it know which user row to update?

why are you talking so stupidly? External image (may be gone) Go and learn mysql INSERT mysql command and about WHERE clause then talk to me . Im giving you links for your mysql tutorial

////////////////////////////////////////////////////
[url]http://dev.mysql.com/doc/refman/5.0/en/insert-select.html[/url]
With INSERT ... SELECT, you can quickly insert many rows into a table from one or many tables. For example: 
INSERT INTO tbl_temp2 (fld_id)
  SELECT tbl_temp1.fld_order_id
  FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
///////////////////////////////////////////////////
[url]http://dev.mysql.com/doc/refman/5.0/en/insert.html#nolinkhere[/url]
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name [(col_name,...)]
    VALUES ({expr | DEFAULT},...),(...),...
    [ ON DUPLICATE KEY UPDATE
      col_name=expr
        [, col_name=expr] ... ]

Or: 
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name
    SET col_name={expr | DEFAULT}, ...
    [ ON DUPLICATE KEY UPDATE
      col_name=expr
        [, col_name=expr] ... ]

Or: 
INSERT [LOW_PRIORITY | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name [(col_name,...)]
    SELECT ...
    [ ON DUPLICATE KEY UPDATE
      col_name=expr
        [, col_name=expr] ... ]
///////////////////////////////////////////////////
[url]http://dev.mysql.com/doc/refman/5.0/en/where-optimizations.html[/url]
This section discusses optimizations that can be made for processing WHERE clauses. The examples use SELECT statements, but the same optimizations apply for WHERE clauses in DELETE and UPDATE statements.
rukiya Lead · 569 posts #29

i have unlimited database dude.... unlimited bandwith.... 2 gigs of space.... and guess what?? its free...well just 4 me thou... its nice 2 have a friend with own host lol...

i just said earlier tht its useles 2 have 10.000 useles rows if the same r nt in use....

its almoust the same if u delete a post at forum, but it stays in database..... 4 what? its useles right?

i think you must have forgotten to read this

Use DELELE sql command mentioning the deletion time if you are anxious about your inadequete db space@alesh

Guest #31

It can be done with minimum 3 fields@advisor pamod

Yep true But i added id field in case i wanna sort out the data and for it to be more neat.. Yea can do it in 3 fields.

khan1 Developer · 101 posts #32

i have recoded it again copy and paste the code in index.php under $action=="viewuser" after the $whonick variable has been declared to show last 1 profile viewer

to show last 10 profile viewers

downloaded last 10 profile viewers script and changed table name to ibwf_lastview , before it was only lastview in sql table just need to know do i have to change sql query insert into ibwf_lastview FROM command is getting table ibwf_lastview INSERT command is inserting in field of table ibwf_lastview is it ? just need to know how to viw last 10 users or is it necessary to complete 10 than only i be able to view

CODE

$lv=getnick_sid($sid); mysql_query("INSERT INTO lastview SET lastview='".$lv."', whonick='".$whonick."', ltime='".time()."'"); $sql= mysql_query("SELECT lastview,ltime FROM ibwf_lastview WHERE whonick='".$whonick."'ORDER BY ltime DESC"); $counter=0; while($row = mysql_fetch_array($sql)){ if($counter<10){ echo "Last viewed by $row[0] "; $newtime =$row[1]+(6 *60 *60); echo "".date("D d M y - H:i:s a",$newtime)." "; echo "------------ "; $counter++; } }

alexism Developer · 136 posts #33

CODE

$lv=getnick_sid($sid); mysql_query("INSERT INTO lastview SET lastview='".$lv."', whonick='".$whonick."', ltime='".time()."'"); $sql= mysql_query("SELECT lastview,ltime FROM ibwf_lastview WHERE whonick='".$whonick."'ORDER BY ltime DESC"); $counter=0; while($row = mysql_fetch_array($sql)){ if($counter<10){ echo "Last viewed by $row[0] "; $newtime =$row[1]+(6 *60 *60); echo "".date("D d M y - H:i:s a",$newtime)." "; echo "------------ "; $counter++; } }

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xxxxx/public_html/web/index.php on line 3184

khan1 Developer · 101 posts #34

CODE

$lv=getnick_sid($sid); mysql_query("INSERT INTO lastview SET lastview='".$lv."', whonick='".$whonick."', ltime='".time()."'"); $sql= mysql_query("SELECT lastview,ltime FROM ibwf_lastview WHERE whonick='".$whonick."'ORDER BY ltime DESC"); $counter=0; while($row = mysql_fetch_array($sql)){ if($counter<10){ echo "Last viewed by $row[0] "; $newtime =$row[1]+(6 *60 *60); echo "".date("D d M y - H:i:s a",$newtime)." "; echo "------------ "; $counter++; } }

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xxxxx/public_html/web/index.php on line 3184

before inserting sql table , did u change it to ibwf_lastview only if your using lavalair script or just change FROM ibwf_lastview to lastview just try

alexism Developer · 136 posts #36

do this code need a coding in core.php?

alexism Developer · 136 posts #37

its show the same viewer for all user..shit..

hypetype Developer · 128 posts #39

this code shows the users who viewed ur profile for today

place on profile in index.php
////////////PROFILE VIEWS/////////////
$vws = mysql_fetch_array(mysql_query("SELECT proviews FROM ibwf_users WHERE id='".$who."'"));
$views = $vws[0]+1;

$dvws = mysql_fetch_array(mysql_query("SELECT dproviews, dayviews, yearviews FROM ibwf_users WHERE id='".$who."'"));
$day = mysql_fetch_array(mysql_query("SELECT DAYOFYEAR(NOW()), YEAR(NOW())"));
$dviews = $dvws[0]+1;

    echo "Profile Views: [b]$views[/b]
";

    echo "Profile Views today: [b]<a href=\"lists.php?action=vwho&who=$who&sid=$sid\">$dviews</a>[/b]
";

/////////EDIT MY PROFILE////////////
  if(mypro(getuid_sid($sid), $who))
  {
  echo "*<a href=\"index.php?action=uset&sid=$sid\">Edit My Profile</a>
";
  }else{
      mysql_query("UPDATE ibwf_users SET proviews='".$views."' WHERE  id='".$who."'");
  $tm = time();

$tzone = mysql_fetch_array(mysql_query("SELECT timezone FROM ibwf_users WHERE id='".$uid."'"));
$hourdiff = "$tzone[0]";
$timeadjust = ($hourdiff * 3600);
$show_time = date("h:i:s a",time() + $timeadjust);
      mysql_query("INSERT INTO ibwf_proviews SET who='".$uid."', user='".$who."', date='".$tm."', time='".$show_time."'");
  }

place in list.php
if($action=="vwho")
{
    $who = $_GET["who"];
    $unick = getnick_uid($who);
    addonline(getuid_sid($sid),"Who Viewed $unick Profile","");
    echo "<card id=\"main\" title=\"Who Viewed $unick Profile\">";
    echo "<p align=\"center\">";
    echo "<img src=\"images/bdy.gif\" alt=\"*\"/>
[size="1"]Users who viewed $unick profile today[/size]
";

    echo "</p>";
    //////ALL LISTS SCRIPT <<
$dvws = mysql_fetch_array(mysql_query("SELECT dproviews, dayviews, yearviews FROM ibwf_users WHERE id='".$who."'"));

    if($page=="" || $page<=0)$page=1;
    $num_items = $dvws[0]; //changable
    $items_per_page= 10;
    $num_pages = ceil($num_items/$items_per_page);
    if(($page>$num_pages)&&$page!=1)$page= $num_pages;
    $limit_start = ($page-1)*$items_per_page;

    //changable sql

        $sql = "SELECT id, who, date, user, time FROM ibwf_proviews WHERE user='".$who."' ORDER BY id DESC LIMIT $limit_start, $items_per_page";

    echo "

";
    $items = mysql_query($sql);
    
    if(mysql_num_rows($items)>0)
    {
    while ($item = mysql_fetch_array($items))
    {
      $jdt = date("H:i:s - M-d-y", $item[2]);
    $nick = getnick_uid($item[1]);
      $lnk = "<a href=\"index.php?action=viewuser&who=$item[1]&sid=$sid\">$nick</a> - [size="1"]Viewed @: $jdt[/size]";
      echo "$lnk
";
    }
    }
    echo "</p>";
    echo "<p align=\"center\">";
    if($page>1)
    {
      $ppage = $page-1;
      echo "<a href=\"lists.php?action=$action&page=$ppage&sid=$sid&view=$view\">«PREV</a> ";
    }
    if($page<$num_pages)
    {
      $npage = $page+1;
      echo "<a href=\"lists.php?action=$action&page=$npage&sid=$sid&view=$view\">Next»</a>";
    }
    echo "
$page/$num_pages
";
    if($num_pages>2)
    {
      $rets = "Jump to page<input name=\"pg\" format=\"*N\" size=\"3\"/>";
        $rets .= "<anchor>[GO]";
        $rets .= "<go href=\"lists.php\" method=\"get\">";
        $rets .= "<postfield name=\"action\" value=\"$action\"/>";
        $rets .= "<postfield name=\"sid\" value=\"$sid\"/>";
        $rets .= "<postfield name=\"page\" value=\"$(pg)\"/>";
        $rets .= "<postfield name=\"who\" value=\"$who\"/>";
        $rets .= "</go></anchor>";

        echo $rets;
    }
    echo "</p>";
  ////// UNTILL HERE >>
    echo "<p align=\"center\">";
    echo "<a href=\"index.php?action=viewuser&who=$who&sid=$sid\">Back To $unick Profile</a>
";
    echo "<a href=\"index.php?action=main&sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>";
echo "Home</a>";
  echo "</p>";
    echo "</card>";
}

the sql
-- --------------------------------------------------------

-- 
-- Table structure for table `ibwf_proviews`
-- 

CREATE TABLE `ibwf_proviews` (
  `id` int(100) NOT NULL auto_increment,
  `who` int(100) NOT NULL default '0',
  `date` int(100) NOT NULL,
  `user` int(100) NOT NULL default '0',
  `time` time NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;

-- 
-- Dumping data for table `ibwf_proviews`
--

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