So i’m not a very good programmer, but I can get some things to work
I have a WordPress site with custom PHP. The page for a fishing competition and is used for storing the weights for the fish catched for each team.
But now I ran into a problem. I have a page that reads some data from my database (fish spicies) and presents them with an inputfield for each spicies represented in the database.
Like this:
$arter = $wpdb->get_results( "SELECT id as artid, artnavn, mindstemaal, sats FROM arter order by artnavn ASC");
if (!empty ($arter)) {
// work with results.
?>
<form action="" method="post" id="form" enctype="multipart/form-data">
<table style="border:none;background-color:#e0e0eb;width:100%;">
<tr>
<?php
foreach ($arter as $art){
?>
<td style="border:none;width:25%">
<?php echo $art->artnavn ?>
</td>
<td style="border:none;">
<input type="text" size="10" name="indvej[<?php echo $art->artid ?>]"> gram
</td>
<td style="border:none;"><font size="2">Mindstemål <?php echo $art->mindstemaal ?> cm</font></td>
<td style="border:none;"><font size="2">Sats <?php echo $art->sats ?></font></td>
</tr>
<tr>
When you input a weight ind the “indvej” field for some of the spicies and submit it is send to a “APPROVE” site.
If($_POST['Submit'])
{
$_SESSION['indvej'] = $_POST["indvej"];
$_SESSION['baadnr'] = $baadnr;
$_SESSION['id'] = $id;
$_SESSION['dag'] = $dag;
?>
<script type="text/javascript">
window.location = "http://localhost/WORDPRESS/?page_id=2";
</script>
On the APPROVE site the spicies with weight submitted is shown
$indvej = $_SESSION['indvej'];
$baadnr = $_SESSION['baadnr'];
$id = $_SESSION['id'];
$dag = $_SESSION['dag'];
foreach($indvej as $x => $x_value)
{
if ($x_value){
$artnavn = $wpdb->get_results( "SELECT ArtNavn FROM arter where id=$x");
?>
echo $artnavn[0]->ArtNavn ?>
echo $x_value ?> gram</b>
Now I can APPROVE and the data is stored in the database, BUT my problem is if I made an error in typing in a weight or if I have to add a spicie more. Then I would like to go back to first page, but with my data for the already typed fish. So when I go back the wieght for the spicies follows with me back. I hope you understand.
I know I have my data in the SESSION variable but how do I get the data out and matchs with the building of the inputfields on page one?