Passing results from query to form to display.

I have a custom table in a Wordpress that stores some data entered by my sites members. I want to allow them to only edit the data that they have entered which I have covered but they may have entered multiple rows of data and so I want them to select which row to edit.

I am using a query to grab all the rows that they have created in the table. I am then offering one colum of these rows as a select list in a form. This is all working fine in the code below. However, on form submit I want to display the rest of the columns from that data row for edit. I would have presumed that the data rows are still available without performing an additional query but this does not seem to be the case as $record in my code is empty. Is this correct? Or have I missed something stupid?

[php]
echo ‘

’;
?>
<form method=“post” action="“id=“studies_frm”>
<?php
echo’Which of your studies do you want to change? ';
$i=0;
foreach ($myrows as $myrow){
echo ‘’ . ucwords(strtolower($myrow->study_name)) . ‘’;
//echo $i.” ".ucwords(strtolower($myrow->study_name)) . “
”;
$i++;
}
echo ’ ';
echo ‘
’;
if (isset($_POST[‘submit’])){
echo “Edit Study”;
$record = ($_POST[‘studies’]);
echo $myrows[$record]->$study_name;
echo $record;
}
if (isset($_POST[‘add_variant’])){
echo “Add a variant”;
}
if (isset($_POST[‘remove_variant’])){
echo “Remove a variant”;
}
[/php]

$myrows stores the result of the custom table query. There is more code above and below this but this is the relevant section.

Any thoughts most welcome

I eventually tracked down the issue a dumb error on my part calling a string instead of an object in line 18.

Sponsor our Newsletter | Privacy Policy | Terms of Service