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
https://forums.phpfreaks.com/topic/213189-question/
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
https://forums.phpfreaks.com/topic/213189-question/#findComment-1110104
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.