Forum Moderators: coopster
<?php
$sql = "SELECT `field` FROM `table`;
$result = mysql_query($sql) or die (mysql_error());
if(mysql_num_rows($result)) {
$value = mysql_result($result, 0);
if($value == "1") {
echo "<p>This is a test.</p>";
}
}
?>
<?php
$sql = "SELECT `field` FROM `table`;
$result = mysql_query($sql) or die (mysql_error());
if(mysql_num_rows($result)) {
$value = mysql_result($result, 0);
if($value == "1") {
echo "<p>This is a test.</p>";
}
}
?>
<?php
$sql = "SELECT `field` FROM `table`;
$result = mysql_query($sql) or die (mysql_error());
if(mysql_num_rows($result) > 0) {
$value = mysql_result($result, 0);
if(!$value) {
echo "<p>No results.</p>";
}
else{
echo "<p>Working.</p>";
}
}
?>
$sql = "SELECT `field` FROM `table` ";
$result = mysql_query($sql) or die (mysql_error());
if(mysql_num_rows($result) > 0) {
while($DataReturned = mysql_fetch_object($result)){
if($DataReturned->field == "1") {
echo "<p>Returned 1.(It works)</p>";
}
}
}
Basically what I need is for the if statement to check if the value on that input field is either 0 or 1, if it is 0 I don't need to echo anything but if it is 1 I need to echo some html. Hope that's better now, thanks so much for the help.
$sql = 'SELECT field FROM table WHERE field = "1"';
$result = mysql_query($sql);
while($row = mysql_fetch_assoc($result)) {
// Echo some HTML here
}
while($row = mysql_fetch_array($result)) {
$value=($row[0]==1)?'Yes':'No';
echo $value;
}
Array ( [0] => 1 [previous_employee] => 1 ) Array ( [0] => 0 [previous_employee] => 0 )
$sql = "SELECT `field` FROM `table` ";
$result = mysql_query($sql);
while($values = mysql_fetch_array($result)){
if($values['previous_employee'] == 1){
echo "Woo! A match";
}
}
if($result['previous_employee'] == 1)
echo "<p>This is a test.</p>";
$SqlQuery = "SELECT * FROM `applications`