Top.Mail.Ru
? ?
PHP Development's Journal
 
[Most Recent Entries] [Calendar View] [Friends View]

Friday, May 16th, 2003

Time Event
3:28p
mysql question
Hi there,

I'm trying to use php and mysql together and I'm finding it a very powerful combination. However I'm missing something which I think must be fundamentally obvious.

When you access data from a specific table, you use a command like:
$link = mysql_connect("localhost", "mysql_user", "mysql_password");

Now the parameters can be replaced with variables you can get from the user through a form or whatever. Great.

You can then select a database using something like:
mysql_select_db ("database", $link);

This can also be replaced with a variable. Again, great.

However, when I want to select all data from a single table I seem to have to use something like:
$result = mysql_query("select * from table", $link);

Then I can use the data out of $result to do whatever I want.

However, I want to be able to make the table in use a variable, but can't seem to find how.

In the long term I'd like to have queries like:
select $a from $table where $a = $b

That kind of thing, so I can use one script to access lots of tables.

Anybody have any ideas what obvious thing I'm missing?

Current Mood: Image confused

<< Previous Day 2003/05/16
[Calendar]
Next Day >>
About LiveJournal.com
Image