I have a table which loads data from mysql per user. Each user will be allowed to change his own data. How can I achieve this?
I tried with several possibilities:
1) Using a "$_GET" and pass the variables via URL
<a href="<? echo ''.$web.'?change='.$show[id].'&beschreibung='.$beschreibung.'&testimonial='.$testimonial.'' ?>">
where $beschreibung & $testimonial are variables from a Text Area. But only "$_GET[change]" -> the ID will be passed to my "if $_GET..."
2) I tried with a button:
<td><? echo '<button type="submit" value="' . $show['id']. '" name="change">Ändern?</button>'; ?></td>
But only the ID will be passed. Even if I send via "POST" (because the form is a type: POST) only the ID will be passed. $testimonial, $beschreibung are empty.
I set those two variables like this:
<td><textarea id='testimonial' name ='testimonial' rows='16' cols='30' style="resize: none;"><?php echo utf8_decode($show['testimonial']); ?></textarea></td>
<td><textarea id='beschreibung' name='beschreibung' rows='16' cols='30' style="resize: none;"><?php echo utf8_decode($show['beschreibung']); ?></textarea></td>
How can I pass the input of $testimonial, $beschreibung via URL, SUBMIT to my SQL Statement?
Here is the complete code:
if (isset($_POST['change'])) {
$referenz = $_POST['testimonial'];
$beschreibung = $_POST['beschreibung'];
$id_change = $_POST['change'];
$project = $_POST['project'];
echo $_GET['project'];
$db = mysql_connect("xxxxxx", "xxxx", "xxxx");
mysql_select_db("xxxx",$db);
$sql = "Update wp_awa_upload set beschreibung = '$beschreibung', testimonial = '$referenz', project= '$project' where id = '$id_change'";
$result = mysql_query($sql, $db);
echo $sql;
//$url = 'http://www.austrianweddingaward.at/awa/';
//echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
}
<table width="800" border="0" align="center" class="box-white">
<thead>
<tr>
<td colspan="4">
</td>
</tr>
<tr>
<th width="96">Kategorie</th>
<th width="299">Beitrag</th>
<th width="100">Name</th>
<th width="299">Referenz</th>
<th width="299">Beschreibung</th>
<th width="299">YouTube</th>
<th width="210"><? if ($rolle == '1') { echo 'Bewertung'; } elseif ($rolle== '9') { echo 'Freischalten';} else { echo 'Status';} ?></th>
<form method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?>" enctype="multipart/form-data">
<? while ($show = mysql_fetch_array($abfrage)) { ?>
</tr>
</thead>
<tbody>
<tr>
<td><? echo $show['parent_cat']; ?></td>
<td><a href="<? echo $show['url']; ?>" data-lightbox="<? echo $show['file_name']; ?>" data-title="<? echo $show['file_name']; ?>"><img src="http://www.austrianweddingaward.at/awa/images/Vorschaubild-01.png" width="150" height="150" border="0"><br></a></td>
<td><? echo $show['file_name']; ?></td>
<td><textarea rows='16' cols='30' readonly style="resize: none;"><?php echo utf8_decode($show['testimonial']); ?></textarea></td>
<td><textarea rows='16' cols='30' readonly style="resize: none;"><?php echo utf8_decode($show['beschreibung']); ?></textarea></td>
<td><? echo "<a href='".$show['youtube']."'>Youtube</a>"; ?></td>
<td><? if ($rolle == '1') { ?>
<select name="rating" class="style28" style="width: 120px" id="rating">
<option value="0">0</option>
<option value="5">5</option>
<option value="15">15</option>
<option value="100">100</option>
</select> <? echo '<button type="submit" value="' . $show['id']. '" name="submit">Bewerten?</button>'; }
elseif ($rolle == 9) {
echo '<button type="freigeben" value="' . $show['id']. '" name="freigeben">Freigeben?</button>';
}?></td>
</tr>
</tbody>
<? }
}?>
</table>
</form>