Jump to content

[SOLVED] If statement not working


jaxdevil

Recommended Posts

What did I do wrong? It keeps showing me the highest numbered row is 20. I have a table with 20 rows, that has a field called 'fldact', which is set either 'yes' or 'no'. I am trying to make an if statement that shows an error and will not show the new item entry form if the fields are all marked as 'yes' for the field 'fldact'. As it is now it ALWAYS says it has 20 rows, it is like it is completely ignoring the WHERE clause limiting the results to only the rows marked 'yes'.

Here is my code...

 

<?php
$sql = "SELECT * FROM `fld` WHERE `fldact`='yes' ORDER BY `id` DESC LIMIT 1";
$query = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($query)) {
$tot = $row['id'];
$k=20;
$fld_id = $row['id'];
$fld_id_text = $row['idtext'];
}
if ($tot=$k){
print "ERROR!<br>";  // This line will not be executed
print "You already have the maximum number of fields<br>";
echo $tot;
echo $k;
}
else{
?>
<input type="hidden" name="fld_id" value="<?=$fld_id?>">
<input type="hidden" name="fld_id_text" value="<?=$fld_id_text?>">
		<p><div style="padding-left: 60px;"><label for="first_name">Field Value <?=$tot?></label>
		<input id="fld_name" name="fld_name" type="text" size="30" />
		</div></p>
<?php
}
?>

Link to comment
https://forums.phpfreaks.com/topic/94131-solved-if-statement-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.