Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

PHP to echo DB field name as a variable

Posted on 2011-09-23
2
292 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Is there a simpler dropbox system? 10 34
Using cfstoredproc to return query data 2 30
reverse engineer .sql from php files 11 33
Where on a calculated field 1 20
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.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

809 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