php - Show records from MySQL Database -


i have php page supposed list of employees positions..

<!doctype html public "-//w3c//dtd html 4.01//en"         "http://www.w3.org/tr/html4/strict.dtd"> <html> <head> <title>view records</title> </head> <body> <?php     // connect database     include('connection.php'); ?> <?php     // results database     $result = "select employees.id, concat( fname, lname ) fullname,     employees.hphone, employees.cphone, employees.email, position.pos\n" . "from employees\n" . "inner join position on employees.posid = position.id\n" . "order employees.id asc limit 0, 30 ";              or die(mysql_error());        // display data in table     echo "<p><b>view all</b> | <a href='view-paginated.php?page=1'>view paginated</a></p>";      echo "<table border='1' cellpadding='10'>";     echo "<tr> <th>id</th> <th>employee name/th> <th>home phone</th> <th>cell phone</th> <th>email</th> <th>position</th> </tr>";      // loop through results of database query, displaying them in table     while($row = mysql_fetch_array( $result )) {              // echo out contents of each row table             echo "<tr>";             echo '<td>' . $row['employees.id'] . '</td>'             echo '<td>' . $row['fullname'] . '</td>';             echo '<td>' . $row['employees.hphone'] . '</td>';             echo '<td>' . $row['employees.cphone'] . '</td>';             echo '<td>' . $row['employees.email'] . '</td>';             echo '<td>' . $row['position.pos'] . '</td>';                             echo '<td><a href="edit.php?id=' . $row['employees.id'] . '">edit</a></td>';             echo '<td><a href="delete.php?id=' . $row['employees.id'] . '">delete</a>    </td>';             echo "</tr>";      }       // close table>     echo "</table>"; ?> <p><a href="drop.php">add new record</a></p> </body> </html>  

but can white page..no errors no nothing....can me please..i using linux mysql , php....i know sql works because can records via myphpadmin..

please help.

try this:

$con=mysqli_connect("example.com","peter","abc123","my_db"); if (!$con)   {   die('could not connect: ' . mysql_error());   }      $sql = "select employees.id, concat( fname, lname ) fullname,     employees.hphone, employees.cphone, employees.email, position.pos\n"     . "from employees\n"     . "inner join position on employees.posid = position.id\n"     . "order employees.id asc limit 0, 30 ";             $result = mysqli_query($con,$sql);     // display data in table     echo "<p><b>view all</b> | <a href='view-paginated.php?page=1'>view paginated</a></p>";      echo "<table border='1' cellpadding='10'>";     echo "<tr> <th>id</th> <th>employee name/th> <th>home phone</th> <th>cell phone</th> <th>email</th> <th>position</th> </tr>";      // loop through results of database query, displaying them in table     while($row = mysqli_fetch_array($result)) {              // echo out contents of each row table             echo "<tr>";             echo '<td>' . $row['employees.id'] . '</td>';             echo '<td>' . $row['fullname'] . '</td>';             echo '<td>' . $row['employees.hphone'] . '</td>';             echo '<td>' . $row['employees.cphone'] . '</td>';             echo '<td>' . $row['employees.email'] . '</td>';             echo '<td>' . $row['position.pos'] . '</td>';                             echo '<td><a href="edit.php?id=' . $row['employees.id'] . '">edit</a></td>';             echo '<td><a href="delete.php?id=' . $row['employees.id'] . '">delete</a>    </td>';             echo "</tr>";      }       // close table>     echo "</table>"; 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -