php - Using PDO to return a single set of values rather than an array -
a nice person on site helped me following script (and worked treat)
<?php $db = new pdo('mysql:host=host;dbname=database', $user, $pass); $stmt = $db->prepare(' select yeast, rating, description, weblink, image, sideimage dowdb_yeast_selector fruit = :fruit order rating desc '); $stmt->bindparam(':fruit',$_post['fruit'],pdo::param_str,50); $stmt->execute();
how echo side image (not part of while loop)?
i think (?) need echo '$row[sideimage]'
// how simple i
all of examples have looked @ far not fit needs :-(
use pdo::fetchall, example;
$stmt->execute(); $arrresults = $stmt->fetchall(); //$arrresults multidimensional //this echo first sideimage echo $arrresults[0]['sideimage'];
if want echo values of sideimage
(ie: rows), you'd have iterate through results;
foreach($arrresults $arrrow) { echo $arrrow['sideimage'] . php_eol; }
Comments
Post a Comment