elie Posted May 24, 2006 Share Posted May 24, 2006 good day to all of you! my page is all about asking a user to input any number of 'equipments' and the output will produce number of sets of fields which the user inputted on the previous page.. i have already the scripts on inserting and viewing these records using mysql and php; these codes are working well already...(inventory1) -- after the user inputted the number[code]. . . <?php for($i=0; $i<$num; $i++) { echo " <tr><td align=center><input type='text' name='field_a[]' size='15'/></td> <td align=center><input type='text' name='field_b[]' size='15'/></td> <td align=center><input type='text' name='field_c[]' size='25'/></td> <td align=center><input type='text' name='field_d[]' size='15'/></td> <td align=center><input type='text' name='field_e[]' size='15'/></td> <td align=center><input type='text' name='field_f[]' size='25'/></td></tr> "; } ?> . . . [/code](inventory2.php) -- the records being inserted in database[code]<?php $field_a = $_POST['field_a']; $field_b = $_POST['field_b']; $field_c = $_POST['field_c']; $field_d = $_POST['field_d']; $field_e = $_POST['field_e']; $field_f = $_POST['field_f']; $num = $_POST['num']; foreach($field_a as $key => $val) { $sql="INSERT INTO inventory (field_a, field_b, field_c, field_d, field_e, field_f, title) VALUES ('".$val."','".$field_b[$key]."','".$field_c[$key]."','".$field_d[$key]."','".$field_e[$key]."','".$field_f[$key]."', '$title')"; $connection = mysql_connect("localhost","root","") or die ("Couldn't connect to server."); $db = mysql_select_db("setup", $connection) or die ("Couldn't select database."); mysql_query($sql) or die(mysql_error()); } . . . [/code](view.php) -- viewing them[code]<?php include("config.php"); $query = "SELECT * FROM inventory where title='$title'"; $result = mysql_query($query) or die(mysql_error()); if($result && mysql_num_rows($result) > 0) { while($row = mysql_fetch_array($result)) { extract($row); echo " <tr> <td>$field_a<br /></td> <td>$field_b<br /></td> <td>$field_c<br /></td> <td>$field_d<br /></td> <td>$field_e<br /></td> <td>$field_f<br /></td> </tr> "; } } [/code]my problem now is how to update the arrayed fields?? in mysql and php?? please help! Link to comment https://forums.phpfreaks.com/topic/10317-how-to-update-arrayed-fields-in-php-and-mysql/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.