update db met input radio
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
<td width="146" align="left" class="submit"><INPUT TYPE="radio" name="style" title="Layout 1" value="style1" checked>Layout 1</td>
<td width="146" align="left" class="submit"><INPUT TYPE="radio" name="style" title="Layout 2" value="style2">Layout 2</td>
<td width="200" rowspan="2" align="center" class="submit"><strong>Binnenkort beschikbaar </strong></td>
</tr>
<tr>
<td width="146" align="left" class="submit"><INPUT TYPE="radio" name="style" title="Layout 3" value="style3" disabled>Layout 3</td>
<td width="146" align="left" class="submit"><INPUT TYPE="radio" name="style" title="Layout 4" value="style4" disabled>Layout 4</td>
<td width="146" align="left" class="submit"><INPUT TYPE="radio" name="style" title="Layout 2" value="style2">Layout 2</td>
<td width="200" rowspan="2" align="center" class="submit"><strong>Binnenkort beschikbaar </strong></td>
</tr>
<tr>
<td width="146" align="left" class="submit"><INPUT TYPE="radio" name="style" title="Layout 3" value="style3" disabled>Layout 3</td>
<td width="146" align="left" class="submit"><INPUT TYPE="radio" name="style" title="Layout 4" value="style4" disabled>Layout 4</td>
Het zou iets in de aard van het volgende moeten zijn:
Code (php)
1
2
3
2
3
<?php
$result = mysql_query("UPDATE login SET style='/*!!!HIER ÉÉN VAN DE 4 STYLES!!!*/' WHERE id='" .mysql_real_escape_string($_SESSION['user_id']). "'")
or die(mysql_error());?>
$result = mysql_query("UPDATE login SET style='/*!!!HIER ÉÉN VAN DE 4 STYLES!!!*/' WHERE id='" .mysql_real_escape_string($_SESSION['user_id']). "'")
or die(mysql_error());?>
Gewijzigd op 01/01/1970 01:00:00 door Ruben Vanhoeyveld
Code (php)
1
2
3
2
3
<?php
$result = mysql_query("UPDATE login SET style='".$_POST['style']."' WHERE id='" .mysql_real_escape_string($_SESSION['user_id']). "'")
or die(mysql_error());?>
$result = mysql_query("UPDATE login SET style='".$_POST['style']."' WHERE id='" .mysql_real_escape_string($_SESSION['user_id']). "'")
or die(mysql_error());?>
Je moet dan wel een formulier (<form>) toevoegen hè, maar misschien heb je die al?
Bedankt, ik probeer het eens uit...
Code (php)
1
2
3
4
5
6
2
3
4
5
6
<?php
if ($_SERVER['REQUEST_METHOD\]=='POST'
isset($_POST['....']) && trim($_POST['....']) != '') {
}
?>
if ($_SERVER['REQUEST_METHOD\]=='POST'
isset($_POST['....']) && trim($_POST['....']) != '') {
}
?>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
if(isset($_POST['layout'])){
$sql = "SELECT name FROM login WHERE layout='".mysql_real_escape_string($_POST['style'])."'";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_object($query);
$buddy_name = htmlspecialchars($row->name);
$style = htmlspecialchars($row->layout);
echo "Je hebt je layout aangepast";
$result = mysql_query("UPDATE login SET layout='".mysql_real_escape_string($_POST['style'])."' WHERE id='" .mysql_real_escape_string($_SESSION['user_id']). "'")
or die(mysql_error());
$style = $_POST['style'];}
?>
if(isset($_POST['layout'])){
$sql = "SELECT name FROM login WHERE layout='".mysql_real_escape_string($_POST['style'])."'";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_object($query);
$buddy_name = htmlspecialchars($row->name);
$style = htmlspecialchars($row->layout);
echo "Je hebt je layout aangepast";
$result = mysql_query("UPDATE login SET layout='".mysql_real_escape_string($_POST['style'])."' WHERE id='" .mysql_real_escape_string($_SESSION['user_id']). "'")
or die(mysql_error());
$style = $_POST['style'];}
?>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<table width="500" border="0" align="center" cellpadding="0" cellspacing="2" class="table">
<tr>
<td colspan="3" align="left" class="head"><div align="center">Layout aanpassen </div></td>
</tr>
<tr>
<td colspan="3" align="center" class="cell"><?php
echo "Je hebt nu ".$style.".";?></td>
</tr>
<tr>
<td width="146" align="left" class="submit"><INPUT TYPE="radio" name="style" title="Layout 1" value="style1" checked>Layout 1</td>
<td width="146" align="left" class="submit"><INPUT TYPE="radio" name="style" title="Layout 2" value="style2">Layout 2</td>
<td width="200" rowspan="2" align="center" class="submit"><input name="layout" type="submit" class="button" id="style" value="Verander" onFocus="if(this.blur)this.blur()" /></td>
</tr>
<tr>
<td width="146" align="left" class="submit"><INPUT TYPE="radio" name="style" title="Layout 3" value="style3" disabled>Layout 3</td>
<td width="146" align="left" class="submit"><INPUT TYPE="radio" name="style" title="Layout 4" value="style4" disabled>Layout 4</td>
</tr>
</table></td>
<tr>
<td colspan="3" align="left" class="head"><div align="center">Layout aanpassen </div></td>
</tr>
<tr>
<td colspan="3" align="center" class="cell"><?php
echo "Je hebt nu ".$style.".";?></td>
</tr>
<tr>
<td width="146" align="left" class="submit"><INPUT TYPE="radio" name="style" title="Layout 1" value="style1" checked>Layout 1</td>
<td width="146" align="left" class="submit"><INPUT TYPE="radio" name="style" title="Layout 2" value="style2">Layout 2</td>
<td width="200" rowspan="2" align="center" class="submit"><input name="layout" type="submit" class="button" id="style" value="Verander" onFocus="if(this.blur)this.blur()" /></td>
</tr>
<tr>
<td width="146" align="left" class="submit"><INPUT TYPE="radio" name="style" title="Layout 3" value="style3" disabled>Layout 3</td>
<td width="146" align="left" class="submit"><INPUT TYPE="radio" name="style" title="Layout 4" value="style4" disabled>Layout 4</td>
</tr>
</table></td>
In de database staat een kolom layout waar een cijfer van 1 tot 4 in komt. Het is de bedoeling dat die daar in komt, door de layout te veranderen bij die radiobolletjes. Het lukt niet echt... Kan iemand zeggen waar het verkeerd gaat?
Is er nog iemand die kan helpen?
Gewijzigd op 01/01/1970 01:00:00 door Ruben Vanhoeyveld
Is er écht niemand?