Jump to content

Question


Joshua F

Recommended Posts

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.

Link to comment
Share on other sites

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. ::)

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.