Jump to content

[SOLVED] if/else


maxudaskin

Recommended Posts

I have a little bit of a script that is not functioning properly.

 

Is there anything wrong?

<?php
$constructionsql = mysql_query("SELECT value FROM config WHERE name='construction'");
while($constructionresult = mysql_fetch_array($constructionsql)){
$construction = $constructionresult['value'];
}
echo 'Construction = '.$construction;
if($construction=1){
echo '<table width="98%" border="0" cellpadding="0">';
echo '<tr>';
echo '<td><div class="status_box">';
echo '<h1 style="text-align: center;" class="status_message status_note">This website is currently under construction.</h1>';
echo '</div></td>';
echo '</tr>';
echo '</table>';
}else{}}
?>

When I call construction() it will always echo the table and contents.

 

Right now, construction = 0.

Link to comment
https://forums.phpfreaks.com/topic/80067-solved-ifelse/
Share on other sites

Try:

<?php
$constructionsql = mysql_query("SELECT value FROM config WHERE name='construction'");
while($constructionresult = mysql_fetch_array($constructionsql)){
$construction = $constructionresult['construction'];
echo 'Construction = '.$construction;
if($construction == 1){
echo '<table width="98%" border="0" cellpadding="0">';
echo '<tr>';
echo '<td><div class="status_box">';
echo '<h1 style="text-align: center;" class="status_message status_note">This website is currently under construction.</h1>';
echo '</div></td>';
echo '</tr>';
echo '</table>';
}
else{
// Blablabal
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/80067-solved-ifelse/#findComment-405758
Share on other sites

<?php
$constructionsql = mysql_query("SELECT value FROM config WHERE name='construction'");
while($constructionresult = mysql_fetch_array($constructionsql)){
$construction = $constructionresult['value'];
}
echo 'Construction = $construction';
if($construction == "1") {
echo '<table width="98%" border="0" cellpadding="0">';
echo '<tr>';
echo '<td><div class="status_box">';
echo '<h1 style="text-align: center;" class="status_message status_note">This website is currently under construction.</h1>';
echo '</div></td>';
echo '</tr>';
echo '</table>';
}
else {
// display content or do something here
}
?>

Link to comment
https://forums.phpfreaks.com/topic/80067-solved-ifelse/#findComment-405760
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.