| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 55361 | 2005-03-09 00:28:00 | php mysql html help | Morgenmuffel (187) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 332032 | 2005-03-09 00:28:00 | Greetings all What I need to do is to pull a selection of values from a database change them and then put them back in see here (nigel.geek.nz) for what I am meaning (the submit button is disabled) the problem is when I am pulling them out I am using a loop mysql_select_db($dbname, $conn); $query_result = "SELECT * FROM store"; $result = mysql_query($query_result, $conn) or die(mysql_error()); while ($row_result = mysql_fetch_array($result)) { echo '<tr><td width="20%">'; echo $row_result["p_name"]; echo '</td><td width="10px">'; echo $row_result['p_no']; echo '</td><td width="15px"><strong><input type="text" name="nz_price" size="10" Value ="'; echo $row_result['nz_price']; echo '"></td><td width="15px"><strong><input type="text" name="us_price" size="10" Value ="'; echo $row_result['us_price']; echo '"></td><td width="15px"><strong><input type="text" name="au_price" size="10" Value ="'; echo $row_result['au_price']; echo '"></strong></td></tr>'; as you can see all text inputs have the same names on each row, what I want to do is to make the names different for each row ie row 1 us_price1 au_price1 au_price1 row 2 us_price2 au_price2 au_price2 row 3 us_price3 au_price3 au_price3 row 4 us_price4 au_price4 au_price4 row 5 us_price5 au_price5 au_price5 and so on thanks Nigel |
Morgenmuffel (187) | ||
| 332033 | 2005-03-09 04:18:00 | Ok no help yet Does anyone know of a good site/forum which specialises in php mysql etc as last time I went to one, and asked a stupid (read newbie) question, the response i got was not overly polite, which is why I stick with pf1 normally. No I am not abandoning PF1 but on such a site my question is liable to have been asked, answered and filed away in the archives thanks |
Morgenmuffel (187) | ||
| 332034 | 2005-03-09 06:33:00 | You are calling all the records in the database . If this is what you want to do, add an update method to each line with a WHERE condition based on a unique identifier . As an alternative use a popup window with the data relating to the specific record to be altered . Again base the popup on a WHERE condition based on a unique identifier . He who laughs, lasts - Mary Pettibone Poole |
merlin (256) | ||
| 332035 | 2005-03-09 07:17:00 | Theres two ways around this, the easy way, and the hard way. The easy way is just displaying the table with 'Edit' at the end of each, that way you can selectively edit each entry with out any hassle. The other way is using your original setup, but making the field names multidimensional arrays and looping over them on form submit. <? mysql_select_db($dbname, $conn); $query = "SELECT * FROM store"; $result = mysql_query($query, $conn) or die(mysql_error()); while ($row_result = mysql_fetch_array($result)) { ?> <tr> <td> <? =$row_result['p_name']?></td> <td> <? =$row_result['p_no']?></td> <td><input type="text" name="prod[ <? =$row_result['p_no']?>][nz_price]" Value =" <? =$row_result['nz_price']?>"></td> <td><input type="text" name="prod[ <? =$row_result['p_no']?>][us_price]" Value =" <? =$row_result['us_price']?>"></td> <td><input type="text" name="prod[ <? =$row_result['p_no']?>][au_price]" Value =" <? =$row_result['au_price']?>"></td> </tr> <? } ?> I'm not entirely sure on how to do this but maybe that might put you in the right direction? Good luck. |
sal (67) | ||
| 332036 | 2005-03-09 10:17:00 | Thanks guys I went with arrays and got it working, eventually i will be doing a litle edit button next to the rows but for now the client wants to update everything on his dB so clicking on edit for each entry will take a while anyway thanks you've given me a few more things to think about |
Morgenmuffel (187) | ||
| 1 | |||||