zlzk Posted April 2, 2006 Share Posted April 2, 2006 given a input form,formated as a table, with $x rows, $y columns, 1. how to collect all the data in each row and column, then insert each row[$x]column[$y] value in the table into database?2. how to retrive it and present it in the same table format as if you are entering it?*********** sample code ************row across are types, column down are colours,for each type, and each color, need to put in a number and record it into database.********************************************************************echo "<table border=\"1\">\n";echo "<tr>\n";// Show Size Type name from selected size_type_id#while ($row = mysql_fetch_array($query_size_name)){ $size_name = $row['size_name']; echo "<th>" . $size_name . "</th>\n";}$color1 = "#ffffff";$color2 = "#ff0000";$row_count = 0;//display color selectionfor ($y=0; $y<$how_many_color; $y++) // get_color_num change to user value{ $row_color = ($row_count % 2) ? $color1 : $color2; echo "<tr bgcolor=\"$row_color\">\n"; echo "<td>\n"; $row_count++; $sql = "SELECT color_name FROM color ORDER BY color_name"; $query = mysql_query($sql); echo "<select name=\"color_id\">"; echo "<option value=\"\"</option>"; for ($x =0; $x<get_size_num($size_type_id); $x++) { while($c_color = mysql_fetch_array($query)) { //assign variable $color_id = $c_color['color_id']; $color_name = $c_color['color_name']; echo "<option value=\"". $color_id . "\">" . $color_name . "</option>"; } // Define colors for the alternating rows echo "<td><input size=\"5\" name=\"$x.$y\"></td>"; } echo "</select>"; echo "</td>"; echo "</tr>\n";} echo "<tr>\n"; echo "<td><input type=\"submit\" value=\"Add All\" name=\"add_all\"></td>"; echo "</tr>\n"; echo "</form>"; echo "</table>\n";*********** end sample code ************ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.