Re: [PHP] newbie PDO query display question

[email protected] (dealTek)
Newsgroups php.general
Message-ID <[email protected]>
>> 
>> 
> When you know there is only one row to be returned you can do this:
> 
> $photo_category_list = "";
>   $SQL = "SELECT category_id, category_name FROM gallery_category ORDER by category_order";
>   try {
>       $stmt = $dbh->prepare($SQL);
>       $stmt->execute();
>       list( $id, $name) = $stmt->fetch(PDO::FETCH_NUM));
>      }
>   }
>   catch (PDOException $e){
>       echo 'Error getting category name. ' . $e->getMessage();
>   }
> 
> echo $id;
> echo $name;
> 
> And you could also do
> 
>       list( $result["id"], $result["name"]) = $stmt->fetch(PDO::FETCH_NUM));
> 
> 
> -- 
> Stephen
> 

Thanks very much for your help Stephen - I will try this asap!




--
Thanks,
Dave - DealTek
[email protected]
[db-3]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.