Solved

PHP to echo DB field name as a variable

Posted on 2011-09-23
2
284 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
Comment Utility
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
Comment Utility
Perfect.
Thank you very much.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now