Solved

PHP to echo DB field name as a variable

Posted on 2011-09-23
2
291 Views
Last Modified: 2012-05-12
Hello Experts,
I have a conditional scenario as below:

$jobmode = {job_mode};
if ($jobmode == '9'){
$export = "recip_mm";
}else if ($jobmode == '7'){
$export = "recip_origin_export";
}else if ($jobmode == '8'){
$export = "recip_origin_export";
}
else{
$export = "recip_export";
}

Open in new window


And the below to insert the record in a table:
/**
 * Insert a record on another table
 */
$insert_table  = 'recip';              // Table name
$insert_fields = array(                   // Field list
                     '$export' => "'{job_vol}'",
);

Open in new window


Everything works fine except that I am not able to post $export to  '$export' => "'{job_vol}'",

How can this be done..
Thanks for any help
0
Comment
Question by:jayseena
2 Comments
 
LVL 13

Accepted Solution

by:
dsmile earned 250 total points
ID: 36586008
Remove single quotes from line 6, or use double quotes instead

$insert_fields = array(                   // Field list
                     $export => "'{job_vol}'",

or

$insert_fields = array(                   // Field list
                     "$export" => "'{job_vol}'",
0
 

Author Closing Comment

by:jayseena
ID: 36586045
Perfect.
Thank you very much.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question