Re: newbie PDO query display question
| From: | dealTek | Date: | Mon, 17 Jun 2013 03:14:52 +0000 |
| Subject: | Re: newbie PDO query display question | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-321419@lists.php.net to get a copy of this message | ||
>>
>>
> 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
dealtek@gmail.com
[db-3]