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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.