Forum Moderators: coopster
$queryleave = "SELECT confirmed FROM challenge WHERE clanid = '$id' OR themid = '$id' and leagueid = '1'";
$resultleave = mysql_query($queryleave);$recordleave= mysql_fetch_assoc($resultleave);
$confirmed = $recordleave['confirmed'];
$queryleave2 = "SELECT confirmed FROM challenge WHERE clanid = '$id' OR themid = '$id' and leagueid = '2'";
$resultleave2 = mysql_query($queryleave2);
$recordleave2= mysql_fetch_assoc($resultleave2);
$confirmed2 = $recordleave2['confirmed'];
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$leagues[]=$row['leagueid'];
if(in_array(1,$leagues) && $confirmed == "")// if user is in ladder with no challenges
{
$box1 = 'checked'; // check box
}
else if (in_array(1,$leagues) && $confirmed!= "") // if user is in ladder with challenges
{
$box1 = 'checked DISABLED';// check box but its locked
$text1 = "cant leave as you have challenges!"; //say reason why box can't be unchecked
}
if(in_array(2,$leagues) && $confirmed2 == "")
{
$box2 = 'checked';
}
else if (in_array(2,$leagues) && $confirmed!= "") // if user is in ladder with challenges
{
$box2 = 'checked DISABLED';// check box but its locked
$text2 = "cant leave as you have challenges!"; //say reason why box can't be unchecked
}
My question is about the query part. Surely i dont need 2 queries here ($queryleave1 AND $queryleave2) . How can i shorted the code? thanks!
If a the user is in league one and they have a match arranged then..
$box1 = 'checked DISABLED';
This is used..
<input type = \"checkbox\" name = \"ctf\" $box1>
it successfully prevents the user from unchecking the box if they have matches arranged.
BUT... If you hit submit, the code sends the box as UNCHECKED when it should be sending it as CHECKED, is this something to do with the disabled button? How can I prevent the user from unchecking the checked box and send the box as checked? thanks!
The following elements support the readonly attribute: INPUT and TEXTAREA.
And you can't use disabled because
Disabled controls cannot be successful.
Essentially, in W3C language, that means they can't get submitted by the form.
So, I think your best solution is this
<input type="checkbox" name="throw_me_away" disabled="disabled" checked="checked">
<input type="hidden" name="ctf" value="test">
That said, you are pulling the checked value from your DB. Why do you need it in your post array on the next page? I guess if that's the only thing you would be pulling from the DB, for the price on one post variable you save yourself then need of querying again.