using pdo want to echo 3 columns from one row

how can I do a select statement
I want one row from table1 using pdo
select table1.column1, table1.column2, table1.column3 where

want to echo
table1.column1, table1.column2, table1.column3
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Marco GasiFreelancerCommented:
Are you sure it is table.Id instead of Anyway look at this

$sth = $dbh->prepare("select table1.column1, table1.column2, table1.column3 where");

$result = $sth->fetch(PDO::FETCH_ASSOC);
echo $result['column1'] . '\n' . $result['column2'] . '\n' . $result[column3'] . '\n';

Open in new window

You find more in Php manual:

Ray PaseurCommented:
This article maps the various MySQL extensions.  The part about that you probably want is in the PDO::Prepare() method, where you would bind the variable containing the  Or the, depending.

If you want one row, do yourself a favor and use LIMIT 1.  See AntiPractice #26
rgb192Author Commented:
$sth = $dbh->prepare("select table1.column1, table1.column2, table1.column3 where");

what about the pdo connection?
db, hostname, username, password

object oriented versus procedural? as in mysqli?
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Marco GasiFreelancerCommented:
For connection see here:
AFAIK, there is no procedural version of PDO, but only oop implementation, which I prefer always:

$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
PDO is object-oriented.  There is no procedural version (nor should there be)!

Search this article for Connect to the Server and Choose the Data Base
rgb192Author Commented:
thank you for connection string
and explanation about object oriented only implementation.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.