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?
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?
