<?php
if(mysql_num_rows(mysql_query("SELECT * FROM downloads_log WHERE ip = '" . $_SERVER['REMOTE_ADDR'] . "')) == 1) {
// what you wanna do
}
?>
Code:<?php if(mysql_num_rows(mysql_query("SELECT * FROM downloads_log WHERE ip = '" . $_SERVER['REMOTE_ADDR'] . "')) == 1) { // what you wanna do } ?>
something like that, might not be exactly right as i just wrote it
<?php
$download_amount = 1 // How many downloads are allowed per IP
$download_amount_per_ip_query = "SELECT * FROM downloads WHERE ip = '".$_SERVER['REMOTE_ADDR']."'";
$download_amount_per_ip = mysql_num_rows($download_amount_per_ip_query);
if($download_amount_per_ip >= $download_amount) {
echo "You already downloaded the max amount of downloads possible per IP";
}
?>
That seems about right, a little update:
PHP:<?php $download_amount = 1 // How many downloads are allowed per IP $download_amount_per_ip_query = "SELECT * FROM downloads WHERE ip = '".$_SERVER['REMOTE_ADDR']."'"; $download_amount_per_ip = mysql_num_rows($download_amount_per_ip_query); if($download_amount_per_ip >= $download_amount) { echo "You already downloaded the max amount of downloads possible per IP"; } ?>
It needs to be before, you can't count the number of rows before you do the query....There needs to be a mysql_query after the num rows
It needs to be before, you can't count the number of rows before you do the query....
$result = mysql_query($query);No... it's mysql_num_rows(mysql_query("query"));
Yeah mysqli is an easier and better way to goWhy not just use MySQLi or PDO - better security, less work & cleaner code (using a wrapper) - With COUNT() function in SQL you can get the number of rows of the column
e.g. COUNT(`ip_addr`) or COUNT(*)