Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,895 questions

51,826 answers

573 users

How to fetch records (rows) form a table into a list() variables with PDO in PHP

1 Answer

0 votes
$con = new PDO("mysql:host=".$db_host.";dbname=".$db_name, $db_user, $db_password);
$result = $con->query("SELECT image_id, href, src FROM images");
while (list($image_id, $href, $src) = $result->fetch(PDO::FETCH_NUM)) 
{
    echo "$image_id : $href : $src" . "<br />";
}


/*
run: 

49 : https://www.ws.com : http://www.ws.com/images/us-flag.gif
50 : https://www.ws.com : http://www.ws.com/images/logo.png
51 : https://www.ws.com : http://www.ws.com/images/discount.png

*/

 



answered Jul 3, 2016 by avibootz
...