hi everyone :)
i know how to show all the records from database in an html table but how would i show specific category.for example i want to show records only with type T (type T is in database).im new with php and i dont know how to do it properly.thankyou here is my code

<?php include("../includes/config.php"); ?>
<title>Admdin Home</title>
<link rel="StyleSheet" href="css/style.css" type="text/css" media="screen">
<?php include("includes/header.php"); ?>
<?php include("includes/nav.php"); ?>
<?php include("includes/aside.php"); ?>
<div id="maincontent">

    <div id="breadcrumbs">
        <a href="">Home</a> >
        <a href="">Manage Users</a> >
        List Users
    <h2>Teachers List</h2>
 if ($_SESSION["isadmin"])

if (!$con)
   die('Could not connect: ' . mysql_error());


mysql_select_db($dbname, $con);
$result = mysql_query("SELECT * FROM accounts WHERE (type=='T')");
echo "<table border='1'>

while($row = mysql_fetch_array($result))
  echo "<tr>";
    echo "<td>" . $row['email'] . "</td>";
  echo "<td>" . $row['firstname'] . "</td>";
  echo "<td>" . $row['lastname'] . "</td>";
    echo "<td>" . $row['type'] . "</td>";
  echo "</tr>";
echo "</table>";


<?php include("includes/footer.php"); ?>
        header("Location: ".$fullpath."login/unauthorized.php");

4 Years
Discussion Span
Last Post by Riu 2009

In MySQL queries, you only use one = char to compare values, not two.

SELECT ... WHERE type = 'T'

Also, you should always check database results before trying to use them. That way, errors like the one above will be much easier to debug. For example:

$sql = "SELECT invalid query";
$result = mysql_query($sql);
if (!$result) {
    trigger_error("MySQL query failed: " . mysql_error(), E_USER_ERROR);

And, while I'm already at it, the mysql_query family of functions - the old MySQL API extension - is deprecated and really shouldn't be used. Instead use PDO or MySQLi.

Edited by Atli


thankyou very much for the additional info thts really helpful thanks again :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.