sjaakdelul
IS-IT--Management
I am using php4.2.2 and the newest version of mysql.
The 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 the follow form in update1.php
<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>[color]
Update1.php will send the data to Update2.php:
<?php
if ( $_POST[vakkeuze]>A ) { $vakkeuze1=$_POST[vakkeuze];
echo "$vakkeuze1<br>";
} else {
echo "Voer de juiste vakafkorting in!!!<br>";
}
// MySQL data
$host = "localhost";
$username = "";
$password = "";
$database = "hrocijfers";
// Make connection to MySQL server
mysql_connect ("$host","$username", "$password"
mysql_select_db("$database"
//Execute query
$sql = 'SELECT * FROM `cijferlijst` WHERE 1 AND `vak` = '. $vakkeuze1 .' LIMIT 0, 30';
$result = mysql_query($sql);
// Checkout the entered vak
$num_rows = mysql_num_rows($result);
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 cijfer2=8 where vak=\'Proj1\'';
$results = mysql_query($query);
echo "Your availability is updated... <br><br>";
echo "<a href=availability2.php>Click here to view the status of other members</a>";
?>
I want to put variables into the 'select' and 'update' line, but all the variants I tried didn't work...
For example:
$query = 'UPDATE cijferlijst set $cijfer1=$cijferinvoer where vak=$vakkeuze1';
$sql = 'SELECT * FROM `cijferlijst` WHERE 1 AND `vak` = \'$vakkeuze1\' LIMIT 0, 30';
$sql = "SELECT * FROM cijferlijst WHERE 1 AND vak = ' . $vakkeuze1 . ' LIMIT 0, 30';
It should be like this:
$query="UPDATE cijferlijst WHERE vak='$vakkeuze1' SET $cijfer1='$cijferinvoer1'"
Who can help me?
The 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 the follow form in update1.php
<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>[color]
Update1.php will send the data to Update2.php:
<?php
if ( $_POST[vakkeuze]>A ) { $vakkeuze1=$_POST[vakkeuze];
echo "$vakkeuze1<br>";
} else {
echo "Voer de juiste vakafkorting in!!!<br>";
}
// MySQL data
$host = "localhost";
$username = "";
$password = "";
$database = "hrocijfers";
// Make connection to MySQL server
mysql_connect ("$host","$username", "$password"
mysql_select_db("$database"
//Execute query
$sql = 'SELECT * FROM `cijferlijst` WHERE 1 AND `vak` = '. $vakkeuze1 .' LIMIT 0, 30';
$result = mysql_query($sql);
// Checkout the entered vak
$num_rows = mysql_num_rows($result);
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 cijfer2=8 where vak=\'Proj1\'';
$results = mysql_query($query);
echo "Your availability is updated... <br><br>";
echo "<a href=availability2.php>Click here to view the status of other members</a>";
?>
I want to put variables into the 'select' and 'update' line, but all the variants I tried didn't work...
For example:
$query = 'UPDATE cijferlijst set $cijfer1=$cijferinvoer where vak=$vakkeuze1';
$sql = 'SELECT * FROM `cijferlijst` WHERE 1 AND `vak` = \'$vakkeuze1\' LIMIT 0, 30';
$sql = "SELECT * FROM cijferlijst WHERE 1 AND vak = ' . $vakkeuze1 . ' LIMIT 0, 30';
It should be like this:
$query="UPDATE cijferlijst WHERE vak='$vakkeuze1' SET $cijfer1='$cijferinvoer1'"
Who can help me?