Broun Posted June 3, 2008 Share Posted June 3, 2008 I have a couple of tables with different input column values. I am trying to update all the table at once but am failing. My problem looks to be my php skills. Please help!!!!! I have this form code which returns the editable data: $rows = pg_num_rows($result); for ($k = 0; $k < $rows; $k++) { for ($j = 0; $j < $i; $j++) { $fieldname = pg_field_name($res, $j); $retu = pg_fetch_result($result,$k,$j) ; if ($fieldname == "gid") echo '<td class="hr">'. htmlspecialchars($retu) ; else echo '<td class="hr"><input name="'.$fieldname.$k. '" type="text" value="'. $retu .'">'; And this is the code for updating the database table: $norows = pg_num_rows($res); $i = pg_num_fields($res); if(isset($_POST['update'])) { $r = 0; while ($r < $norows) { $sql1 = 'UPDATE'." $editable SET "; for ($j = 0; $j < $i; $j++) { $type .= pg_field_type($res, $j); $fieldname = pg_field_name($res, $j); if ($j==$i-1 ) { $sql1 .= " $fieldname = ".@$_POST.'[ \''. $fieldname.$r.'\' ] '; } else { $sql1 .= " $fieldname = ".@$_POST.'[ \''. $fieldname.$r.'\' ] '.', ' ; } } $s = ($r+1) ; $sql1 .= "WHERE gid=$s".'; '; //$result1= pg_query($conn,$sql1); echo "$sql1"; ++$r; } } else But then i get this output! UPDATE material_parameters SET gid = Array[ 'gid0' ] , name = Array[ 'name0' ] , manning = Array[ 'manning0' ] , eqrough = Array[ 'eqrough0' ] , hazenwilliam = Array[ 'hazenwilliam0' ] , darcyweisbach = Array[ 'darcyweisbach0' ] WHERE gid=1; etc etc Link to comment https://forums.phpfreaks.com/topic/108556-multiple-postgres-database-columns-update/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.