Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php select from database into array

<?php

// run query
$query = mysql_query("SELECT * FROM table");

// set array
$array = array();

// look through query
while($row = mysql_fetch_assoc($query)){

  // add each row returned into an array
  $array[] = $row;

  // OR just echo the data:
  echo $row['username']; // etc

}

// debug:
print_r($array); // show all array data
echo $array[0]['username']; // print the first rows username
Comment

PREVIOUS NEXT
Code Example
Php :: laravel created_at where date format 
Php :: eloquent model sort by ascending order 
Php :: laravel join 
Php :: how to set a validation on a value if its not null in laravel php 
Php :: wordpress check if page is password protected 
Php :: codeigniter order by random 
Php :: a facade root has not been set phpunit 
Php :: difference of two dates in seconds php 
Php :: wordpress notice 
Php :: PHP strtotime() Function 
Php :: random integer php 
Php :: append to collection laravel 
Php :: serve in localhost using php 
Php :: publish Laravel mail pages to customize 
Php :: laravel get subdomain 
Php :: Target class [Controller] does not exist. 
Php :: return last inserted id in laravel 
Php :: how to get woocommerce category image 
Php :: count with left join in laravel 
Php :: flatten a multi-dimensional array into a single array in php 
Php :: php mongodb version cmd 
Php :: laravel limit foreach 
Php :: compile custom/plain css with mix in laravel 
Php :: multiple middleware laravel 
Php :: delete all cookies in php 
Php :: tl to usd 
Php :: get values from text file php 
Php :: mkdir permission denied php 
Php :: html php pass data to another page 
Php :: php send telegram message to user 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =