Show all elements of an array. :: Loops ::

Information for PHP. Hypertext Preprocessor
Post Reply
dzcadii
Posts: 94
Joined: Sun Mar 01, 2015 4:36 am

Show all elements of an array. :: Loops ::

Post by dzcadii » Sun Mar 01, 2015 6:30 pm

Simple way to display all elements of an array.
This array can be from $_GET/$_POST or MYSQL query

Code: Select all

<?
/*********************************
From $_GET/$_POST
*********************************/
foeach($_GET as $key => $value){
echo $value . "<br>";//You can for mat with HTML right here too
}
?>

Code: Select all

<?
/*********************************
From MYSQL :: Show all recursive::
*********************************/
//Link to the DB and select it before
//Run a simple query
$query = mysql_query("SELECT * FROM DatabaseTable");
$info = mysql_fetch_assoc($query);
foreach($info as $key => $value){
echo $value . "<br>"; //or you can format with HTML
}
?>

Code: Select all

<?
/*********************************
From MYSQL :: Get all but show selective::
*********************************/
//Link to the DB and select it before
//Run a simple query
$query = mysql_query("SELECT * FROM DatabaseTable");
while($info = mysql_fetch_assoc($query)){
extract($info);
echo $database_table_fileld_by_name . "<br>"; //or you can format with HTML
}
?>

Post Reply