sjaakdelul
IS-IT--Management
I am using php4.2.2 and the newest version of mysql.
Database:
CREATE TABLE cijferlijst (
Kwartaal int(1) default NULL,
vak varchar(5) default NULL,
cijfer1 varchar(4) default NULL,
cijfer2 varchar(4) default '-',
cijfer3 varchar(4) default '-',
cijfer4 varchar(4) default '-',
Studiepunten char(2) default '-',
Oordeel varchar(100) default 'Nog niet afgesloten'
)
I've one form:
<form name="form" method="post" action="update2.php">
<table width="500" border="0" cellpadding="5" cellspacing="0">
<?php
// MySQL data
$host = "localhost";
$username = "";
$password = "";
$database = "hrocijfers";
// Make connection to MySQL server
mysql_connect ("$host","$username", "$password"
mysql_select_db("$database"
// Execute query
$query = "SELECT * FROM `cijferlijst`";
$results = mysql_query($query);
// Create dropdown box
?>
<tr><td>Vak afkortingen:</td>
<td><div align="left"><? echo "<select name=vak>";
// List vakken into the box
while ($results_array = mysql_fetch_array($results)) {
$name = $results_array['vak'];
echo "<option value='" . $name . "'>" . $name . "</option>";
}
echo "</select>";
?></div></td>
</tr>
<tr><td>Afkorting vak:</td>
<td><div align="left">
<input type="text" name="vakkeuze" value="<?=$_POST['vakkeuze']?>">
</div></td></tr>
<tr><td>Behaalde cijfer:</td>
<td><div align="left">
<input type="text" name="cijferinvoer" value="<?=$_POST['cijferinvoer']?>">
</div></td></tr>
<tr><td>Hoeveelste cijfer:</td>
<td><div align="left">
<input type="text" name="cijfer" value="<?=$_POST['cijfer']?>">
</div></td></tr>
</table>
<input type="hidden" name="required" value="cijferinvoer">
<input type="submit" name="submit" value="submit">
</form>
Update2.php
<?php
if ( $_POST[vakkeuze]>A ) { $vakkeuze1=$_POST[vakkeuze];
echo "$vakkeuze1<br>";
} else {
echo "Fill in a good name!!!<br>";
}
// MySQL data
$host = "localhost";
$username = "upclan";
$password = "jXZDSuXw";
$database = "clanupclan";
// Make connection to MySQL server
mysql_connect ("$host","$username", "$password"
mysql_select_db("$database"
//Execute query
$query = "SELECT * FROM `cijferlijst` WHERE vak='$vakkeuze1'";
$results = mysql_query($query);
// Checkout the entered vak
$num_rows = mysql_num_rows($results);
if ( $num_rows>0 ) {
echo "password oke<br>";
}
else {
echo "Voer de juiste vak afkorting in.<br>";
}
if ( $_POST[cijferinvoer]>0 ) { $cijferinvoer1=$_POST[cijferinvoer];
echo "$cijferinvoer1<br>";
} else {
echo "voer een cijfer in dat groter is dan nul<br>";
}
if ( $_POST[cijfer]>0 ) { $cijfer1=$_POST[cijfer];
echo "$cijfer1<br>";
} else {
echo "voer een cijfer in dat groter is dan nul<br>";
}
// Execute query
$query = 'UPDATE cijferlijst set $cijfer1=$cijferinvoer where vak=$vakkeuze1';
$results = mysql_query($query);
echo "Ok";
?>
There are 5 steps.
1) Set $vakkeuze1
2) Set $cijferinvoer1
3) Set $cijfer1
4) Check vak
5) Update the table cijferlijst.
The steps 1,2 and 3 are going very well...but the steps 4 and 5 aren't good.
Step 4:
I've filled out the form:
Afkorting vak:Bekn1
Cijfer:8
Hoeveelste cijfer:1
The result from update2.php is:
Bekn1
Voer de juiste vak afkorting in.
8
1
Ok
So, the cause of the problem start at "// Checkout the entered vak" ...
But what's wrong?
Step5:
I think the code to update the table cijferlijst is good ... anyone who can see any wrong code?
Who can help me?
Database:
CREATE TABLE cijferlijst (
Kwartaal int(1) default NULL,
vak varchar(5) default NULL,
cijfer1 varchar(4) default NULL,
cijfer2 varchar(4) default '-',
cijfer3 varchar(4) default '-',
cijfer4 varchar(4) default '-',
Studiepunten char(2) default '-',
Oordeel varchar(100) default 'Nog niet afgesloten'
)
I've one form:
<form name="form" method="post" action="update2.php">
<table width="500" border="0" cellpadding="5" cellspacing="0">
<?php
// MySQL data
$host = "localhost";
$username = "";
$password = "";
$database = "hrocijfers";
// Make connection to MySQL server
mysql_connect ("$host","$username", "$password"
mysql_select_db("$database"
// Execute query
$query = "SELECT * FROM `cijferlijst`";
$results = mysql_query($query);
// Create dropdown box
?>
<tr><td>Vak afkortingen:</td>
<td><div align="left"><? echo "<select name=vak>";
// List vakken into the box
while ($results_array = mysql_fetch_array($results)) {
$name = $results_array['vak'];
echo "<option value='" . $name . "'>" . $name . "</option>";
}
echo "</select>";
?></div></td>
</tr>
<tr><td>Afkorting vak:</td>
<td><div align="left">
<input type="text" name="vakkeuze" value="<?=$_POST['vakkeuze']?>">
</div></td></tr>
<tr><td>Behaalde cijfer:</td>
<td><div align="left">
<input type="text" name="cijferinvoer" value="<?=$_POST['cijferinvoer']?>">
</div></td></tr>
<tr><td>Hoeveelste cijfer:</td>
<td><div align="left">
<input type="text" name="cijfer" value="<?=$_POST['cijfer']?>">
</div></td></tr>
</table>
<input type="hidden" name="required" value="cijferinvoer">
<input type="submit" name="submit" value="submit">
</form>
Update2.php
<?php
if ( $_POST[vakkeuze]>A ) { $vakkeuze1=$_POST[vakkeuze];
echo "$vakkeuze1<br>";
} else {
echo "Fill in a good name!!!<br>";
}
// MySQL data
$host = "localhost";
$username = "upclan";
$password = "jXZDSuXw";
$database = "clanupclan";
// Make connection to MySQL server
mysql_connect ("$host","$username", "$password"
mysql_select_db("$database"
//Execute query
$query = "SELECT * FROM `cijferlijst` WHERE vak='$vakkeuze1'";
$results = mysql_query($query);
// Checkout the entered vak
$num_rows = mysql_num_rows($results);
if ( $num_rows>0 ) {
echo "password oke<br>";
}
else {
echo "Voer de juiste vak afkorting in.<br>";
}
if ( $_POST[cijferinvoer]>0 ) { $cijferinvoer1=$_POST[cijferinvoer];
echo "$cijferinvoer1<br>";
} else {
echo "voer een cijfer in dat groter is dan nul<br>";
}
if ( $_POST[cijfer]>0 ) { $cijfer1=$_POST[cijfer];
echo "$cijfer1<br>";
} else {
echo "voer een cijfer in dat groter is dan nul<br>";
}
// Execute query
$query = 'UPDATE cijferlijst set $cijfer1=$cijferinvoer where vak=$vakkeuze1';
$results = mysql_query($query);
echo "Ok";
?>
There are 5 steps.
1) Set $vakkeuze1
2) Set $cijferinvoer1
3) Set $cijfer1
4) Check vak
5) Update the table cijferlijst.
The steps 1,2 and 3 are going very well...but the steps 4 and 5 aren't good.
Step 4:
I've filled out the form:
Afkorting vak:Bekn1
Cijfer:8
Hoeveelste cijfer:1
The result from update2.php is:
Bekn1
Voer de juiste vak afkorting in.
8
1
Ok
So, the cause of the problem start at "// Checkout the entered vak" ...
But what's wrong?
Step5:
I think the code to update the table cijferlijst is good ... anyone who can see any wrong code?
Who can help me?