Re: counter help
From: Greg (greg_at_aperfectnumber.com)
Date: 03/14/05
- Next message: steve: "Server not found"
- Previous message: New_: "Re: phpBB Fetch All"
- In reply to: MS: "Re: counter help"
- Next in thread: Beauregard T. Shagnasty: "Re: counter help"
- Reply: Beauregard T. Shagnasty: "Re: counter help"
- Reply: Oli Filth: "Re: counter help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 13 Mar 2005 16:52:25 -0800
Well, I tried that stuff, and nothing seems to work. Any other experts can
shed some light on my problem? Thanks for the efforts of the other posters.
Here's the current php:
<?
require ('dbconnect.php');
$query = "SELECT num FROM counter";
$result = mysql_query($query);
while( $row = mysql_fetch_array( $result ) )
{
echo( "You Have seen this page " . $row["num"] ." times");
}
$i = $row["num"];
++$i;
$query2 = "UPDATE counter SET num = $i";
mysql_query($query2);
echo ("<br><br>Update Complete - Refresh to view new value.");
mysql_close();
?>
"MS" <SpamNoThnx_santa____clause@hotmail.com> wrote in message
news:d12isr$2nj$1@hercules.btinternet.com...
> $row["num"] = $i;
>
> makes $row["num"] equal to $i
>
> by the looks of it you should make $i equal the $row["num"] and then
> increment $i
>
> $i = $row["num"];
> $i++;
>
> hope this helps
> --
> --------------------------------------------------------------------------
-- > http://www.clickonlingerie.com?SIG - Exotic Erotic Lingerie > -------------------------------------------------------------------------- -- > > > "Floortje" <floortje-apestaartjexs4allpuntnl@hetminnetjehoort.erbij> wrote > in message news:mn.6d1e7d5361d62b07.23446@hetminnetjehoort.erbij... > > Greg had uiteengezet : > > > Hello All, > > > > > > I'm getting pretty good with getting tutorial scripts to function, and > now > > > I'm trying to experiment on my own with PHP. I'm trying to develop a > simple > > > counter. Before PHP I've never really been able to think like a > programmer, > > > but the code below seems logical to me. First, the script connects to > the > > > database and retrieves the value in the "counter" table, row "num". It > > > returns this value to the brower. Then it assigns that row to another > > > variable, that I increment with the ++ . Then it updates the database > with > > > the new number. Where am I going wrong with the script. Please be > gentle, > > > I"m pretty green. > > > > > > > Dunno seems okay, maybe small error .. havent tried it cause im lazy > > ... try this instead > > > > $sql= "SELECT num FROM counter LIMIT 1"; > > $query = mysql_query("$sql") > > or exit ("Ongeldige query " . mysql_error()); > > > > $row = mysql_fetch_array($result); > > echo "You Have seen this page " .$row["num"] ." times"; > > > > $sql= "UPDATE counter SET num = num+1"; > > $query = mysql_query("$sql") > > or exit ("Ongeldige query " . mysql_error()); > > > > > > > > > > > > PHP SCRIPT: > > > > > > <? > > > require ('dbconnect.php'); > > > > > > $query = "SELECT num FROM counter"; > > > $result = mysql_query($query); > > > > > > while( $row = mysql_fetch_array( $result ) ) > > > { > > > echo( "You Have seen this page " .$row["num"] ." times"); > > > } > > > > > > $row["num"] = $i; > > > > > > ++$i; > > > > > > $query2 = "UPDATE counter SET num = $i"; > > > > > > mysql_query($query2); > > > > > > echo ("<br><br>Update Complete - Refresh to view new value."); > > > > > > mysql_close(); > > > > > > ?> > > > > -- > > www.cavalierpage.com > > > >
- Next message: steve: "Server not found"
- Previous message: New_: "Re: phpBB Fetch All"
- In reply to: MS: "Re: counter help"
- Next in thread: Beauregard T. Shagnasty: "Re: counter help"
- Reply: Beauregard T. Shagnasty: "Re: counter help"
- Reply: Oli Filth: "Re: counter help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|