Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

Count link doesnt work

General discussions related to php

Moderators: macek, egami, gesf

Count link doesnt work

Postby Kostikz » Mon Oct 15, 2012 10:35 pm

Hello , i trying to make a function with advertisiments and which will count , how many people opened that website , for now on it only display advertisiments , but doesnt count and i dont know why :( , here is a code:

Code: Select all
function Adverts($link) {
$result = mysqli_query($link, "SELECT * FROM Adverts ORDER BY ID DESC LIMIT 4");

$counts = $Info['Counts'];
$hits = 0;

   while($Info = mysqli_fetch_array($result))
  {
   echo " <a href=".$Info['Website']."  target=\"_blank\"><img src=".$Info['Image']." alt=".$Info['Hint']." height=\"60\" width=\"100\"></a> ";
   
              if(isset($Info['Website'])) {
      $refresh = mysqli_query($link, "UPDATE Adverts SET Counts=$hits WHERE ID=$id");
      $hits += 1;
}
  }
 
$id = $_GET['ID'];

$result = mysqli_query($link, "SELECT `Counts` FROM Adverts WHERE `ID`= $id");

$counts = $Info['Counts'];
$hits = 0;
}


And here is html:

Code: Select all

<!------------------------->
<div id="kitos">
<!------------------------->
         <fieldset id="LoginoArRegistracija">
            <legend align="center" style="font-size:130%;"> Member Menu </legend>
            <br>
               <form form action="http://Kostikz666.us.lt/sys/admin/login.php" method="post">
                  <em>Username: </em><input type="text" name="username" size="15" /><br>
                  <em>Password: </em><input type="password" name="password" size="16" />
                     <br>
                  <input type="submit" value="Login"/>
                  <a href="http://Kostikz666.us.lt/sys/registration/Uzsiregistruotis.php"><input type="Button" value="Sign Up"/></a>
               </form>
         </fieldset>
         
         <fieldset id="Advert">
            <legend align="center" style="font-size:130%;"> Ad</legend>
            <br>
               <div id="paciosrekl">
                  <?php
                     Adverts($link);
                  ?>
               </div>
         </fieldset>
</div>



Hope you will help :)
Kostikz
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Oct 03, 2012 9:30 am

Re: Count link doesnt work

Postby egami » Tue Oct 16, 2012 8:01 am

mysql_fetch_array will return a numeric array unless you specify "MYSQL_ASSOC" as such.

mysql_fetch_array($query,"MYSQL_ASSOC");

otherwise, try mysql_fetch_assoc($query);
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: Count link doesnt work

Postby jinijames » Mon Nov 05, 2012 4:30 am

Try this -

<?php
$a[0] = 1;
$a[1] = 3;
$a[2] = 5;
$result = count($a);
// $result == 3

$b[0] = 7;
$b[5] = 9;
$b[10] = 11;
$result = count($b);
// $result == 3

$result = count(null);
// $result == 0

$result = count(false);
// $result == 1
?>

hire php developer | hire magento developer
jinijames
New php-forum User
New php-forum User
 
Posts: 20
Joined: Fri Oct 19, 2012 4:32 am
Location: India


Return to PHP General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.