The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

PHP Counter script tutorial

View previous topic View next topic Go down

PHP Counter script tutorial

100% 100% 
[ 2 ]
0% 0% 
[ 0 ]
 
Total Votes : 2

PHP Counter script tutorial

Post by LUDAKLUDI on December 12th 2008, 12:22 pm

plz guys put post counter on forums .... i have 23000 post

some topics have 20 pages ... my friends and members want post counter i realy need that on forum








Overview
<table width="100%" border="0" cellpadding="0" cellspacing="5"> <tr> <td>In this tutorial create 1 file
1. counter.php


Step
1. Create table "counter" in database "test".
2. Create file counter.php.
</td>
</tr>
</table>





<table width="100%" bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="3"> <tr> <td><table width="100%" bgcolor="#f4f9fb" border="0" cellpadding="0" cellspacing="1"> <tr> <td width="5%"></td>
<td width="95%">Create table "counter"</td>
</tr>
<tr> <td colspan="2" bgcolor="#eeeeee"></td>
</tr>
<tr> <td colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="5">
<tr> <td>
CREATE TABLE `counter` (
`counter` int(9) NOT NULL default '0'
) TYPE=MyISAM;
</td>
</tr>
<tr> <td align="center">
<table width="100" bgcolor="#cccccc" border="0" cellpadding="0" cellspacing="1"> <tr> <td></td>
</tr>
</table></td>
</tr>

</table></td>
</tr>
</table></td>
</tr>
</table>








Create file counter.php
<table width="100%" border="0" cellpadding="0" cellspacing="5">
<tr> <td class="Arial"> ############### Code


$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="members"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect
to server ");
mysql_select_db("$db_name")or die("cannot select DB")

$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);

$rows=mysql_fetch_array($result);
$counter=$rows['counter'];

// if have no counter value set counter = 1
if(empty($counter)){
$counter=1;
$sql1="INSERT INTO $tbl_name(counter) VALUES('$counter')";
$result1=mysql_query($sql1);
}

echo "You 're visitors No. ";
echo $counter;

// count more value
$addcounter=$counter+1;
$sql2="update $tbl_name set counter='$addcounter'";
$result2=mysql_query($sql2);

mysql_close();
?></td></tr></table>

PHP Counter script tutorial
http://www.jooria.com/details-33.html


thx in advance !
yea and i know this request expist ... but i must post this again !

LUDAKLUDI
Forumember

Male Posts : 280
Reputation : 3
Language : English,Serbian
Location : Serbia-Belgrade

Back to top Go down

Re: PHP Counter script tutorial

Post by Jophy on April 3rd 2013, 8:31 am

Suggestion Clean up

-> Old suggestions(Please feel to create a new thread for the garbaged old suggestions)
-> Implemented & Rejected suggestions
-> Suggestions which are currently suggested (Please use the SEARCH function)
-> Unclear Suggestions

=> Please read the guidelines for the suggestion section: http://help.forumotion.com/t93899-suggestions-for-your-forums-how-to
=> Please take a look on the frequently suggested features for your forums:
http://help.forumotion.com/t79095-frequently-requested-suggestions-for-your-forums

Locked & Garbaged

Jophy

Jophy
ForumGuru

Male Posts : 17924
Reputation : 835
Language : English
Location : Somewhere

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum