My goal is to have info from a database echoed out and then available to be purchased by pressing a button. The info is being echoed properly but when the button is pressed it adds the $cost variable up for all of the qualifying variable vs the single one that it should be attached to… hopefully that makes sense.
Also, when I refresh the page the “credits” are deducted from the users account, I was under the impression that a button would stop this from happening…
[code=php]
$get = mysql_query(“SELECT * FROM ac WHERE state=’Alabama’ ORDER BY datetime DESC LIMIT $start, $per_page”);
while ($row = mysql_fetch_assoc($get))
{
$cost = $row[‘cost’];
$submit = $_POST[‘submit’];
if ($submit)
{
if(loggedin())
{
if ($credits<$cost)
{
$option2 = “../../buycredits.php”;
}
else
{
$option2 = “ac_alabama.php”;
$get;
$deduct = mysql_query(“UPDATE users SET credits=credits-$cost WHERE username=’$username'”);
}
}
else
$option2 = “home.html”;
}
echo”
<form action=’$option2′ method=’POST’>
<input type=’submit’ name=’submit’ value=’Purchase’>
</form>
“;
}
Any and all help is greatly appreciated!
Thanks in advance.