Joshua F Posted September 12, 2010 Share Posted September 12, 2010 I am trying to make it so that it will load if the site if the site is online(EG. $siteonline = 1), and so on. I can't seem to think of how I could do this so it will work from the very top of the page's html, to the very bottom. Like the following code is meant to list all of the stuff in that database. <?php $list_q = mysql_query("SELECT * FROM settings") or die (mysql_error()); while($list_f = mysql_fetch_assoc($list_q)) { } ?> I have my page laid out like this.. <?php include "includes/connect.php"; include "includes/config.php"; ?> <?php $list_q = mysql_query("SELECT * FROM settings") or die (mysql_error()); while($list_f = mysql_fetch_assoc($list_q)) { ?> Html content etc.. <?php } include 'includes/footer.php'; ?> But if I do it that way, It only displays what is in footer.php. Quote Link to comment Share on other sites More sharing options...
shlumph Posted September 12, 2010 Share Posted September 12, 2010 You should redirect at the top, after your necessary includes, if the site is not online. Hope this helps. Quote Link to comment Share on other sites More sharing options...
Joshua F Posted September 12, 2010 Author Share Posted September 12, 2010 You should redirect at the top, after your necessary includes, if the site is not online. Hope this helps. This would work, but I'll have the site loading sitename from a database too, and that will be throughout the page(Title, Header, Footer) Quote Link to comment Share on other sites More sharing options...
WatsonN Posted September 12, 2010 Share Posted September 12, 2010 Would something like this work? if ($siteonline == 1){ include 'http://www.example.com/file.php?'; } Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted September 12, 2010 Share Posted September 12, 2010 I am not using your code but just a standard one, but i think you get the idea: I am using a database column named active, and a table named settings. $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $result = mysql_query("SELECT * FROM settings LIMIT 1"); // i assume you only have 1 row in your settings table while($row = mysql_fetch_array($result)) { if($row['active']!= 1){ // your condition here, can be anything, you could set it to != 'monkeys' if you like : ) exit; // or what ever you like die() header location () etc etc } else{ //output your stuff to display here. } } mysql_close($con); Hope i could have been of any help. Quote Link to comment Share on other sites More sharing options...
Joshua F Posted September 12, 2010 Author Share Posted September 12, 2010 Oh... I found the problem, it was I forgot to add a table into the database. Sorry for wasting your time guys. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.