|
Posted by pablo k on 10/26/05 18:04
Dear Newsgroupers,
I have been stupid.
I was struggling with an update query on a text field. When i
updated '19/05' the update was performed and the result was 3.80.
So i decided to set the variable with
settype( $nummer, string ) ;
Now, the result was 1.
Then i tried not to enter the division sign but the hash sign
instead (19#5). That worked to well! I got the message back that all
399 records had been changed!
But I am still wondering what happened?
Could you please shed some light on the code?
------------
....
$sql= "SELECT tid, titel, nr_jrg FROM titels WHERE tid>480 ORDER BY
tid DESC" ;
if ( isset( $_POST['id'] ) && isset( $_POST['nummer'] ) ) {
$id = $_POST['id'] ; $nummer = $_POST['nummer'] ;
settype( $nummer, string ) ;
print $_POST['nummer']. "- - " . $_POST['id']. "--<br> " ;
//n.b.: de apostrophes om '$nummer' heen, anders is het geen tekst
$upd = "UPDATE titels SET nr_jrg = '$nummer' WHERE tid = $id " ;
$res=mysql_query( $upd, $verb ) ;
if ( !$res ) die ('Kan niet updaten! > ' . mysql_error() ) ;
print "<h2>Tabel bijgewerkt! " . mysql_affected_rows() . " rij(en)
gewijzigd.</h2><p>" ;
} else {
print "Er is niets gebeurd!<br>" ;
}
?>
<p></p><br>
<form action="bewerkNrJrg.php" method="POST">
<select name="id" tabindex="0">
<?php
$res = mysql_query( $sql, $verb ) ;
while( $rij = mysql_fetch_object( $res ) ) {
print "<OPTION VALUE =\"$rij->tid\"" ;
if ( isset($_POST['id']) && $_POST['$id'] == $rij->tid ) {
print " SELECTED" ;
}
// $tit = substr($rij->titel,0,75) ;
// print "> $rij->nr_jrg - $tit :: $rij->tid\n" ;
print "> $rij->nr_jrg\n" ;
}
// mysql_close() ;
// mysql_free_result( $res );
?>
</select><br><br>Vul de nieuwe NR_JRG in:
<input type="text" name="nummer">
</form>
....
-----------
tia
pablo
Navigation:
[Reply to this message]
|