Thanks for taking the time to read my question.
I have a form that I want to use to edit data that is in my DB. I'm using $form->value in the value="" part of my <input />.
I have a query that returns the data that should go into the form, but the value="" field is alrealy taken by $form->value. So I was thinking that if I could fill the $form->value array, I could get my data into the form to edit the data. I just can't figure out how to do that.
Any help would be great.
eg:
So when the form loads $form->value() does not equal anything, but I do want to put data in that field, data that the user would like to edit.
Below was Added Later
Kept fooling around with it...
I've tried:
$retval is the result of
didn't work, nothing shows up in my form... which works when I enter bad data. The data shows up in my form for the user to edit.
Below was Added Even Later
What is the form.php expecting for an array? I made up an array and assigned it to $_SESSION['value_array'], with and without the key in the array. If I put the proper field name in as the key to the value I get stuck on
The error shows up on my form instead of the data...
Ok, more findings
I have this code:
If I run it this way I get an error. If I reverse the comment out and make everything that is commented out, active and vice versa, it works. Now it's static, not dynamic, so it's not quite what I need. The array that $_SESSION['value_array'] is being set to is the echo $arraystring;
Why does it not work when I make $_SESSION['value_array'] = $arraystring; ???
Thanks,
Brad
I have a form that I want to use to edit data that is in my DB. I'm using $form->value in the value="" part of my <input />.
I have a query that returns the data that should go into the form, but the value="" field is alrealy taken by $form->value. So I was thinking that if I could fill the $form->value array, I could get my data into the form to edit the data. I just can't figure out how to do that.
Any help would be great.
eg:
- Code:
<input class="inputalign" id="ss<?php echo $x; ?>" name="ss<?php echo $x; ?>" value="<?php echo $form->value('ss'.$x); ?>" />
So when the form loads $form->value() does not equal anything, but I do want to put data in that field, data that the user would like to edit.
Below was Added Later
Kept fooling around with it...
I've tried:
- Code:
$_SESSION['value_array']=$retval;
$retval is the result of
- Code:
$retval=$database->query($q);
didn't work, nothing shows up in my form... which works when I enter bad data. The data shows up in my form for the user to edit.
Below was Added Even Later
What is the form.php expecting for an array? I made up an array and assigned it to $_SESSION['value_array'], with and without the key in the array. If I put the proper field name in as the key to the value I get stuck on
- Code:
function value($field){}
The error shows up on my form instead of the data...
Ok, more findings
I have this code:
- Code:
//$_SESSION['value_array'] = array('scHT1'=>'Capitols', 'scHTG1'=>'34', 'scAT1'=>'Ice Cats', 'scATG1'=>'44', 'scGD1'=>'2010-04-11', 'scGT1'=>'13:15:00', 'scHT2'=>'Manitoba Maple Leafs', 'scHTG2'=>'99', 'scAT2'=>'Ice Cats', 'scATG2'=>'98', 'scGD2'=>'2010-04-02', 'scGT2'=>'13:15:00');
$fieldnames=array('scHT','scHTG','scAT','scATG','scGD','scGT');
$x=1;
$y=0;
while ($row = mysql_fetch_assoc($retval)) {
foreach($row as $value){
if(!isset($arraystring)) {
$arraystring = "'" . $fieldnames[$y] . $x . "'" . "=>" . "'" . $value . "'";
//echo $fieldnames[$y] . $x . " " . $value ."<br />";
}
else {
$arraystring = $arraystring . ", '" . $fieldnames[$y] . $x . "'" . "=>" . "'" . $value . "'";
}
$y++;
}
$y=0;
$x++;
}
$arraystring = "array(" . $arraystring . ")";
//echo $arraystring;
$_SESSION['value_array'] = $arraystring;
header("Location: ".$session->referrer);
If I run it this way I get an error. If I reverse the comment out and make everything that is commented out, active and vice versa, it works. Now it's static, not dynamic, so it's not quite what I need. The array that $_SESSION['value_array'] is being set to is the echo $arraystring;
Why does it not work when I make $_SESSION['value_array'] = $arraystring; ???
Thanks,
Brad