php - functions not showing tables

94

Soo this is giving me errors and idk why, table does exist but still not working, what did i do wrong ?

The content does show but still giving errors and not displaying what it should

function content_temp()
{
    if(isset($_GET['action']))
    {
        if($_GET['action'] == 'banlist')
        {
            echo " <div class='positiontable'>
          <table class='MYTABLE'>
          <tr CLASS='MYTABLE'>
                    <th CLASS='MYTABLE' height=40 width=80>User</th>
                    <th CLASS='MYTABLE' height=40 width=80>Time</th>
                    <th CLASS='MYTABLE' height=40 width=180>Reason</th>
                    <th CLASS='MYTABLE' height=40 width=80>Admin</th>
                  </tr>
                  </table>
                  </div> ";

        $query ="SELECT * FROM `Banovi` LIMIT 5"; 
        $row = mysqli_fetch_array($query);
        if($row)
            $name = $row['Ime'];
            $time = $row['Vreme'];
            $reason = $row['Razlog'];
            $admin = $row['Admin'];
            echo " <tr CLASS='MYTABLE'>
                <td CLASS='MYTABLE' height=40 width=80>$name</td>
                <td CLASS='MYTABLE' height=40 width=80>$time</td>
                <td CLASS='MYTABLE' height=40 width=180>$reason</td>
                <td CLASS='MYTABLE' height=40 width=80>$admin</td>
              </tr>";           
        }
    }
}
27

Answer

Solution:

UPDATE 2

you might need do some changes:

function content_temp( $con ){
  if(isset($_GET['action'])){
    if($_GET['action'] == 'banlist'){
      echo " <div class='positiontable'>
        <table class='MYTABLE'>
          <thead>
            <tr CLASS='MYTABLE'>
              <th CLASS='MYTABLE' height=40 width=80>User</th>
              <th CLASS='MYTABLE' height=40 width=80>Time</th>
              <th CLASS='MYTABLE' height=40 width=180>Reason</th>
              <th CLASS='MYTABLE' height=40 width=80>Admin</th>
            </tr>
          </thead>
          <tbody>";
          $query ="SELECT * FROM `Banovi` LIMIT 5"; 
          $result = mysqli_query($con,$query);
          while( $row = mysqli_fetch_array($result,MYSQLI_ASSOC) ){

            $name = $row['Ime'];
            $time = $row['Vreme'];
            $reason = $row['Razlog'];
            $admin = $row['Admin'];
            echo "
              <tr CLASS='MYTABLE'>
                <td CLASS='MYTABLE' height=40 width=80>$name</td>
                <td CLASS='MYTABLE' height=40 width=80>$time</td>
                <td CLASS='MYTABLE' height=40 width=180>$reason</td>
                <td CLASS='MYTABLE' height=40 width=80>$admin</td>
              </tr>";
          }?>
        </tbody>
      </table><?php           
    }
  }
}

UPDATE 1

Incontent_temp( $con ), the$con should be created and passed upon function call:

$con = mysqli_connect("localhost","my_user","my_password","my_database");
content_temp( $con );

People are also looking for solutions to the problem: php - stock passwords outside document root

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.