Search
 
SCRIPT & CODE EXAMPLE
 

PHP

showing database table in php

$connection = mysql_connect('localhost', 'root', ''); //The Blank string is the password
mysql_select_db('hrmwaitrose');

$query = "SELECT * FROM employee"; //You don't need a ; like you do in SQL
$result = mysql_query($query);

echo "<table>"; // start a table tag in the HTML

while($row = mysql_fetch_array($result)){   //Creates a loop to loop through results
echo "<tr><td>" . $row['name'] . "</td><td>" . $row['age'] . "</td></tr>";  //$row['index'] the index here is a field name
}

echo "</table>"; //Close the table in HTML

mysql_close(); //Make sure to close out the database connection
Comment

PREVIOUS NEXT
Code Example
Php :: I need help 
Php :: stream_set_blocking 
Php :: pasar variables con cronjob 
Php :: php get current url host 
Php :: php close session 
Php :: how to run a specific test in laravel 
Php :: google client php get inbox messages 
Php :: get image name and extension laravel 
Php :: laravel command progress 
Php :: how check if method is not in class in php 
Php :: php get file type from url 
Php :: unique sql queries laravel 
Php :: get http code curl php 
Php :: str_replace php variable 
Php :: get table name of model laravel inside the model 
Php :: create date from string php 
Php :: forever loop php 
Php :: 500 error php 
Php :: maximum characters laravel validation 
Php :: get the unique rows from table laravel 
Php :: php reader read date from excel 
Php :: current user laravel 
Php :: HTML Snippets not working in .php files 
Php :: post json php 
Php :: counting time execution duration in time laravel 
Php :: integer nullable laravel 
Php :: php array to csv 
Php :: remove decimal php 
Php :: start php session 
Php :: convert a php array into a javascript array 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =