Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A Variable Variable

Status
Not open for further replies.

likelylad

IS-IT--Management
Jul 4, 2002
388
GB
This post is a follow on from the following thread:
As it stands my code looks like this and it does exactly what I want it to do
Code:
// MySQL Connection String
$column=$_GET[thedesc];
parse_str($_POST['data']);
 
for ($i = 0; $i < count($callcentreColumn1); $i++) {   
    // The following line is for the MySQL query.   
mysqli_query($db,"INSERT INTO tablename (Tabname,ColumnNumber) VALUES('$column','$callcentreColumn1[$i]')");   
}

The problem I have, is where the words callcentreColumn1 exists. This can/will be different nearly every time, so my question is how to correctly use the correct variable.

The variable name is been received using:
Code:
$column=$_GET[thedesc];
Therefore the $column maybe equal to callcentreColumn1 or accountsColumn1 or lionsColumn1 etc


I hope I am being clear.
 
Ended up figuring it out myself

This is the code that I am working off now:
Code:
// MySQL Connection String
$column=$_GET[thedesc];
parse_str($_POST['data']);
 
for ($i = 0; $i < count(${$column}); $i++) { 
$data=${$column}[$i];  
    // The following line is for the MySQL query.   
mysqli_query($db,"INSERT INTO tablename (Tabname,ColumnNumber) VALUES('$column','$data')");   
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top