Can someone tell me why this function will not work?? When utilize this function I am passing variables from a for loop. To populate a table that lists checks.
I call it with checkcash($checkno,$action).
When the page initially prints the action is null and it just returns a form button. But when the form button is clicked the action is set to cashcheck. But when I click the button it cashes all the checks not just the one clicked.
function checkcash($checkno,$action) {
global $link;
mysql_select_db("checkbook", $link);
$sql = "SELECT cash FROM checks WHERE checkno = '$checkno'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
if ($action == "cashcheck" && $row[cash] == "N") {
mysql_select_db("checkbook", $link);
$sql = "UPDATE checks SET
cash = 'Y'
WHERE checkno = '$checkno'";
mysql_query($sql);
$action = "";
$row[cash] = "Y";
}
if ($row[cash] == "Y") {
echo "Yes";
}
else {
echo "<form action='master.php'>
<input type='hidden' name='checkno' value='$checkno'>
<input type='hidden' name='action' value='cashcheck'>
<input type='submit' name='Submit' class='but' value='Cash'>
</form>";
}
}