Jump to content

[SOLVED] table names for queries


ShaolinF

Recommended Posts

Hi Guys

 

Im trying to carry out an SQL statement using object oriented methods but am having some problems. See code below:

 

$field = $_GET['statment']; /*Specifies table name*/

 

$db->query("INSERT INTO $wpdb->$field ($query)VALUES ($query_data)");

 

The problem is with the $wpdb->$field - It doesn't work when I use the $field var. If I use a table name like posts in its place then the code will work. But what I want to do is specify the table name in the GET method and feed it into the $field variable. That way, I won't need to make several queries with the different tables to do this. Does anyone know how I can do this?

Link to comment
https://forums.phpfreaks.com/topic/110446-solved-table-names-for-queries/
Share on other sites

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.