Ok, so basically I have a query that returns an array, and then it gets looped:
$result = mssql_query("SELECT * FROM Segments ORDER BY Squares");
if (!$result) {
echo 'query failed';
exit;
}
while ($row = mssql_fetch_array($result)) {
$txtsquares = $row["Squares"];
echo $txtsquares;
When echoed the variable $txtsquares is equal to an array value, for example lets say 1 2 3 4 5 6 7 8.
I need this array/loop. But I would like to grab the first value of this array and use it in an if statement, like so:
value="<?php echo $txtsquares; ?>"
<?php if ($txtsquares == 1) { ?> checked="checked" <?php }
else{ ?> checked="" <?php } ?>/>
However obviously this is wrong, because the value will never equal 1 because its an array. Can anyone point me in the correct direction? I am new at PHP so sorry if it is an easy question, I have Googled it but without much luck.