|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-08-23 18:14 UTC] subjective@php.net
[2017-08-23 18:29 UTC] subjective@php.net
-Status: Open
+Status: Not a bug
[2017-08-23 18:29 UTC] subjective@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 06:00:01 2025 UTC |
Description: ------------ Dont print values from array obtained from database use foreach loop Test script: --------------- <?php try { $base=new PDO('mysql:host=localhost;dbname=mydatabase','root','12345678'); $base->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); $base->exec("SET CHARACTER SET UTF8"); $reg=$base->query("SELECT * FROM articles WHERE client='Myclient' ORDER BY article_state desc limit 1,2")->fetchAll(PDO::FETCH_OBJ); foreach($reg as $articles=>$value) { echo $value; } } catch (Exception $e) { die ("Error ".$e->getMessage()); echo "Line error : ".$e->getLine(); } ?> Expected result: ---------------- Myarticle1,Desc1,Desc2 Myarticle2,Desc1,Desc2 Myarticle3,Desc1,Desc2 . . . . . .