Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am using php4.2.2 and the newest

Status
Not open for further replies.

sjaakdelul

IS-IT--Management
Sep 19, 2002
43
NL
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=&quot;form&quot; method=&quot;post&quot; action=&quot;update2.php&quot;>
<table width=&quot;500&quot; border=&quot;0&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;>
<?php
// MySQL data
$host = &quot;localhost&quot;;
$username = &quot;&quot;;
$password = &quot;&quot;;
$database = &quot;hrocijfers&quot;;

// Make connection to MySQL server
mysql_connect (&quot;$host&quot;,&quot;$username&quot;, &quot;$password&quot;);
mysql_select_db(&quot;$database&quot;);

// Execute query
$query = &quot;SELECT * FROM `cijferlijst`&quot;;
$results = mysql_query($query);

// Create dropdown box
?>
<tr><td>Vak afkortingen:</td>
<td><div align=&quot;left&quot;><? echo &quot;<select name=vak>&quot;;
// List vakken into the box
while ($results_array = mysql_fetch_array($results)) {
$name = $results_array['vak'];
echo &quot;<option value='&quot; . $name . &quot;'>&quot; . $name . &quot;</option>&quot;;
}
echo &quot;</select>&quot;;
?></div></td>
</tr>
<tr><td>Afkorting vak:</td>
<td><div align=&quot;left&quot;>
<input type=&quot;text&quot; name=&quot;vakkeuze&quot; value=&quot;<?=$_POST['vakkeuze']?>&quot;>
</div></td></tr>
<tr><td>Behaalde cijfer:</td>
<td><div align=&quot;left&quot;>
<input type=&quot;text&quot; name=&quot;cijferinvoer&quot; value=&quot;<?=$_POST['cijferinvoer']?>&quot;>
</div></td></tr>
<tr><td>Hoeveelste cijfer:</td>
<td><div align=&quot;left&quot;>
<input type=&quot;text&quot; name=&quot;cijfer&quot; value=&quot;<?=$_POST['cijfer']?>&quot;>
</div></td></tr>
</table>
<input type=&quot;hidden&quot; name=&quot;required&quot; value=&quot;cijferinvoer&quot;>
<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;submit&quot;>
</form>[color]

Update1.php will send the data to Update2.php:

<?php
if ( $_POST[vakkeuze]>A ) { $vakkeuze1=$_POST[vakkeuze];
echo &quot;$vakkeuze1<br>&quot;;
} else {
echo &quot;Voer de juiste vakafkorting in!!!<br>&quot;;
}
// MySQL data
$host = &quot;localhost&quot;;
$username = &quot;&quot;;
$password = &quot;&quot;;
$database = &quot;hrocijfers&quot;;

// Make connection to MySQL server
mysql_connect (&quot;$host&quot;,&quot;$username&quot;, &quot;$password&quot;);
mysql_select_db(&quot;$database&quot;);

//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 &quot;password oke<br>&quot;;
}
else {
echo &quot;Voer de juiste vak afkorting in.<br>&quot;;
}

if ( $_POST[cijferinvoer]>0 ) { $cijferinvoer1=$_POST[cijferinvoer];
echo &quot;$cijferinvoer1<br>&quot;;
} else {
echo &quot;voer een cijfer in dat groter is dan nul<br>&quot;;
}

if ( $_POST[cijfer]>0 ) { $cijfer1=$_POST[cijfer];
echo &quot;$cijfer1<br>&quot;;
} else {
echo &quot;voer een cijfer in dat groter is dan nul<br>&quot;;
}
//Execute query
$query = 'UPDATE cijferlijst set cijfer2=8 where vak=\'Proj1\'';
$results = mysql_query($query);
echo &quot;Your availability is updated... <br><br>&quot;;
echo &quot;<a href=availability2.php>Click here to view the status of other members</a>&quot;;
?>


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 = &quot;SELECT * FROM cijferlijst WHERE 1 AND vak = ' . $vakkeuze1 . ' LIMIT 0, 30';


It should be like this:
$query=&quot;UPDATE cijferlijst WHERE vak='$vakkeuze1' SET $cijfer1='$cijferinvoer1'&quot;

Who can help me?
 
You say you are using MySQL....this is the Microsoft SQL Server forum. You might end up getting an answer in this forum, but you're better off posting in the MySQL forum.

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top