Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

PHP + MYSQL Vote System [HELP]

Junior Spellweaver
Joined
Jul 1, 2012
Messages
112
Reaction score
36
Hello all RageZone

Look need make a vote system ( Vote each 12 Hours ( Need IP + Server Vote Time ) )

Look.. i have this..

MYSQL Tables =>

DB_Server

create table DB_Server(
JID int(25) NOT NULL,
Name varchar(25) NOT NULL,
Website varchar(60) NOT NULL,
MaxLevel varchar(10) NOT NULL,
Exp varchar(10) NOT NULL,
SP varchar(10) NOT NULL,
Gold varchar(10) NOT NULL,
Item varchar(10) NOT NULL,
Version varchar(10) NOT NULL,
Server_IP varchar(20) NOT NULL,
Server_Port varchar(10) NOT NULL,
Reg_Page varchar(100) NOT NULL,
Comment varchar(300) NOT NULL,
Rank varchar(15) NOT NULL,
rating INT NOT NULL DEFAULT '0'
);

DB_VoteIP

create table DB_VoteIP(
Vote_IP varchar(30)NOT NULL,
Date varchar(50)NOT NULL
);

Site to See a Rank + Vote

PHP:
<?php $result = mysql_query("SELECT * FROM DB_Server order by rating desc");?>

<table width='1000' border='0' align="center" cellpadding='0' cellspacing='5' class='shadow'>
	<tbody>
	<tr>
		<td width='38' height="19" align='center' class='server_round'><strong>Nr.</strong></td>
    <td width='128' class='server_round' align='center'><strong>Server Name</strong></td>
		<td width='84' class='server_round' align='center'><strong>Level</strong></td>
		<td width='38' class='server_round' align='center'><strong>Exp</strong></td>
		<td width='34' class='server_round' align='center'><strong>SP</strong></td>
		<td width='37' class='server_round' align='center'><strong>Item</strong></td>
		<td width='39' class='server_round' align='center'><strong>Gold</strong></td>
		<td width='79' class='server_round' align='center'><strong>Status</strong></td>
		<td width='123' align="center" class='server_round' ><strong>Votes</strong></td>
		<td width='345' class='server_round' > </td>
	</tr>
<?php	
	$i = 1;
	while($row = mysql_fetch_array($result))
  {
		$site = "".$row['Server_IP']."";
		$port = "".$row['Server_Port']."";
	
	?> 
  <tr>
        <td height="36" align='center' class='round'>
	<?php 
		
		if ($i==1) echo " ".$i." ";
		else if ($i==2) echo " ".$i." ";
		else if ($i==3) echo " ".$i." ";
		else echo $i;
		?>
</td> 		
    <td class='round' align='center'><a href="<?php echo "".$row['Website'].""?>"><?php echo "".$row['Name'].""?></a></td>
		<td class='round' align='center'><?php echo "".$row['MaxLevel'].""?></td>
		<td class='round' align='center'><?php echo "".$row['Exp'].""?>x</td>
		<td class='round' align='center'><?php echo "".$row['SP'].""?>x</td>
		<td class='round' align='center'><?php echo "".$row['Item'].""?>x</td>
		<td class='round' align='center'><?php echo "".$row['Gold'].""?>x</td>
	    <td class='round' align='center'> <?php  print GetServerStatus($site, $port)?> </td>
	    <td align='center' valign="middle" class='round'><form action='' method='post'>
		<input type="hidden" name='Name' value=<?php echo "".$row['Name'].""?> >
	<input type='image' name='Send' src="Style/img/vote.png" value=<?php echo "".$row['Name'].""?> /> 
	<?php echo "Votes: ".$row['rating'].""?>
	    </form></td>
    <td align='center' valign="middle" class='round'></td>
	</tr>
<?php	
		$i++;	
	
	}
?>  
</tbody>
</table>

<?php 


if(isset($_POST['Send'])) 
{ 
   if($_POST['Name'] == '' 

	) 
    { 
		echo 'Please fill out all fields.'; 
	} 
	
		else 
	{  
	$_Name	= $_POST['Name'];
		/*$UserIP = "".$_SERVER[REMOTE_ADDR]."";*/
	$VoteTime = date("Y/m/d H:m:s");
		
		/*$IPFind = mysql_query ("select * from DB_VoteIP WHERE Vote_IP='".$UserIP."'");

		if ($IPFind)
	
		echo "Vote Each 12 Hours";
		else { */

	$sql ="UPDATE DB_Server SET rating= rating + 1 WHERE Name='".$_Name."'";
		mysql_query($sql);
		echo 'Your Already ';
		
	$VoteData =" INSERT INTO DB_VoteIP (Vote_IP,Date) VALUES('".$_SERVER[REMOTE_ADDR]."','".$VoteTime."')";
		mysql_query($VoteData); 
		echo 'Vote.';
	/*}*/
	}
	} 
?> 
<!--img id="Negative" src="Style/img/dislike.gif" /><img id="Positive" src="Style/img/like.gif" style="display: none;"/>

Need a code to add Vote.. Please Help me Coder's :love:
 
Last edited:
Newbie Spellweaver
Joined
Dec 3, 2006
Messages
72
Reaction score
31
Why not just check out other sources in the multiple development sections? There's quite a few with vote functions that I'm sure you could replicate pretty easily.
 
Junior Spellweaver
Joined
Jul 1, 2012
Messages
112
Reaction score
36
Come guys help me ... now vote add.. now my problem is need put vote each 12 Hours..

PHP:
( Register IP and Date ) = > Read Date if12 Hours ++ Vote else echo 12 Hours--- NO VOTE!
 
Newbie Spellweaver
Joined
Dec 3, 2006
Messages
72
Reaction score
31
Check for date/time of last vote -> if 12+ hours, allow vote -> if not, don't allow vote

EDIT: I suggest that you check in terms of their IP address and not their account name or id, by the way.
 
Newbie Spellweaver
Joined
Oct 17, 2008
Messages
21
Reaction score
87
I want to ask what is this?
PHP:
<?php 
        
        if ($i==1) echo " ".$i." ";
        else if ($i==2) echo " ".$i." ";
        else if ($i==3) echo " ".$i." ";
        else echo $i;
        ?>
 
Junior Spellweaver
Joined
Jul 1, 2012
Messages
112
Reaction score
36
I want to ask what is this?
PHP:
<?php 
        
        if ($i==1) echo " ".$i." ";
        else if ($i==2) echo " ".$i." ";
        else if ($i==3) echo " ".$i." ";
        else echo $i;
        ?>

for the first 3 would add color or whatever I want.
 
Experienced Elementalist
Joined
Dec 18, 2007
Messages
243
Reaction score
37
for the first 3 would add color or whatever I want.

Why not just echo the $i whatever the count is? That would be exactly the same thing you are doing right there. What you are doing is basically this, if $i = 1,2 or 3 -> echo the $i, if not, echo $i.

Just echo the $i at all times instead with a prefixed color if that was what you was thinking of.
 
Back
Top