Jump to content

Not displaying table


knifeh

Recommended Posts

Hi guys im kinda new to php so im probably struggling on the most basic thing in the world, anyways i've coded and index.php so that when a user is not logged in it shows a table with text saying not logged in, only problem is. is that the table and text arent showing.

 

<?php
require_once('function.php');
connect();

$sesuser = $_SESSION['username'];

if(loggedin())
{
        if(isset($_SESSION['username'])){
            $sesuser = $_SESSION['username'];
        }else {
            $sesuser = $_COOKIE['username'];
        }
        $query4 = mysql_query("SELECT * FROM users WHERE username='$sesuser'");
        while($rowrow = mysql_fetch_assoc($query4)){
            $admin = $rowrow['admin'];
        }
        if($admin){
        header('location: admin.php'); 
        } else if(!$admin){
            echo "Welcome back $sesuser";
            } else if(!logged_in())
?>
<html>
<link href="style/main.css" rel="stylesheet" type="text/css" />
<body>
<table width="68%" border="1" align="center">
  <tr>
    <td height="74" colspan="3"> </td>
  </tr>
  <tr>
    <td colspan="3" height="30"> 
<?php {
echo "You are not logged in! <a href='login.php'>Click here to login</a><br>";
    echo "Or if you are not registered and wish to do so, please <a href='register.php'>click here</a>";
?>
</td>
  </tr>
  <tr>
    <td height="347" colspan="3"> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>  
  <?php 
         }
      }
?>			
</table>
</body>
</html>

i really have no idea what i've done wrong any help would be appreciated!!

Thanks in advance guys

Luke

Link to comment
https://forums.phpfreaks.com/topic/192405-not-displaying-table/
Share on other sites

It is because you have your table code in a bad spot, that could be causing a syntax error.

 

            } else if(!logged_in()) { //note that I moved the brace up here where it should be
?>
<html>
<link href="style/main.css" rel="stylesheet" type="text/css" />
<body>
<table width="68%" border="1" align="center">
  <tr>
    <td height="74" colspan="3"> </td>
  </tr>
  <tr>
    <td colspan="3" height="30"> 
<?php 
echo "You are not logged in! <a href='login.php'>Click here to login</a><br>";
    echo "Or if you are not registered and wish to do so, please <a href='register.php'>click here</a>";
?>

 

Not sure if that is what you were trying to achieve, but yea. That will display your table if the user is not logged in.

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.