Jump to content

Retrieve DB row contents to PHP variables


stevedun

Recommended Posts

Hello all!

 

I have a MySQL DB set up, and I want to import data into a webpage.  I'm having problems finding the right code. I need to:

 

1. Send a SELECT query that will get an entire row from my DB, based on the key column "B_id".

 

2. Put the info into variables based on the column names in the table ($name = "B_name", $IDnum = "B_id", etc).

 

3. Make the variables show up (echo '$name', etc).

 

I am a major PHP n00b, and I'm really trying to figure this stuff out, but I could use a tutor ^^.  Thank you so much community!

in all of the WWW and the vast number of postings on this site alone, you haven't been able to find anything on extracting data from a database using php?  just typing "extracting data from a database using php" into google and i get tons of great resources.

 

'cause you basically have it right in your post .. SELECT your data from your database (look up how to use the SELECT method using mySQL and PHP).

 

learn by doing .. don't mean to be harsh, but it's the best way there is.

Thank you mrMarcus for putting me in my place.... and thanks Silverado for the useful links.

anytime kiddo .. just a little frustrated here with some code i've been working on for a bit.

 

honestly though, PHP is a very logical language .. always plan out beforehand what it is you are trying to accomplish, whether it be writing it out on paper or whatever.  organization is crucial.

 

so with what you are trying to do is get data from your database.  so, break it down...

 

first, we need to connect to the db.

 

second, we need to access the data.

 

third, figure out what to do with that data .. loop it, etc...

 

fourth, display that data.

 

breaking things down will not only help you learn more efficiently, but will save you many a'headaches in the future as your coding becomes more and more complex.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.