Hello.
At the minute I'm storing a line similar to:
"Dear $title $fName[0] $sName, Can you confirm your email address is $email".
And then I have in a PHP page dropdown box where the value of an option is equal to the above line. I then have some Javascript which echo's out the value of the dropdown selection. The variables, $title, $fName & $sName already exist in the code, so I want it to print the contents of those 3 variables but it's not. It's printing the variable names.
How would it be possible for a loop that creates a dropdown list to echo the contents of a variable in the dropdown value?
[SOLVED] Storing variable names in a MySQL DB
Moderator: General Moderators
-
impulse()
- Forum Regular
- Posts: 748
- Joined: Wed Aug 09, 2006 8:36 am
- Location: Staffordshire, UK
- Contact:
[SOLVED] Storing variable names in a MySQL DB
Last edited by impulse() on Fri Feb 23, 2007 6:26 am, edited 1 time in total.
-
impulse()
- Forum Regular
- Posts: 748
- Joined: Wed Aug 09, 2006 8:36 am
- Location: Staffordshire, UK
- Contact:
So far I have tried to use eval but it's not returning any data. Here is my code so far:
There are 2 templates in the DB at the moment, they look like this:
1. "echo "fName sName";"
2. "echo "{$fName} {$sName}";
Code: Select all
$title = $_POST["title"];
$fName = $_POST["fName"];
$sName = $_POST["sName"];
$email = $_POST["email"];
$notes = $_POST["notes"];
while ($res = mysql_fetch_array($query)) {
$template[$i] = $res['template'];
$i++;
}
<select name = 'OperationDropDown' onChange = 'fillText()'>
<option value = '' selected = 'true'> Select an operation </option>
<?php
for ($i = 0; $i < count($template); $i++) {
echo "<option value = '";
eval($template[$i]);
"'> Template $i </option>";
}
echo "<option value = '$templateTest'> Template Test </option>";
?>
</select> <br><br>1. "echo "fName sName";"
2. "echo "{$fName} {$sName}";
-
impulse()
- Forum Regular
- Posts: 748
- Joined: Wed Aug 09, 2006 8:36 am
- Location: Staffordshire, UK
- Contact:
I just eval'd the whole line, rather than part:
And template[$i] would equal:
Code: Select all
for ($i = 0; $i < count($template); $i++) {
eval($template[$i]);
}Code: Select all
echo "<option value = '$fName'> $i </option>";- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact: