lioslios Posted January 6, 2012 Share Posted January 6, 2012 guys in this code i get some data from myswl table and i display them in to and html table with dynamic textboxes the first part works ok but how can i update the mysqltable with tha changes? i have try to work with one table and i get an error Notice: Undefined index: name1 in D:\....... <?php session_start(); include($_SERVER['DOCUMENT_ROOT'].'/includes/connection.php'); $result = mysql_query( "SELECT * FROM serv " ); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<tr>"; echo "<td ALIGN=\"center\"><form method='POST'><input name=\"name1\" type=\"text\" value={$row['onoma-eponymo']} id=\"n1\" STYLE=\" border-color:black; border-style:none; border-width:1px; font-size:30pt; color:yellow; background-color:gray; \" size=\"25\" maxlength=\"24\" /></form></td>"; echo "<td ALIGN=\"center\"><form method='POST'><input name=\"name2\" type=\"text\" value={$row['username']} STYLE=\" border-color:black; border-style:none; border-width:1px; font-size:30pt; color:yellow; background-color:gray; \" size=\"7\" maxlength=\"5\" /></form></td>"; echo "<td ALIGN=\"center\"><form method='POST'><input name=\"name3\" type=\"text\" value={$row['password']} STYLE=\" border-color:black; border-style:none; border-width:1px; font-size:30pt; color:yellow; background-color:gray; \" size=\"7\" maxlength=\"5\" /></form></td>"; echo "<td ALIGN=\"center\"><form method='POST'><input name=\"name4\" type=\"text\" value={$row['serv_id']} STYLE=\" border-color:black; border-style:none; border-width:1px; font-size:30pt; color:yellow; background-color:gray; \" size=\"9\" maxlength=\"15\" /></form></td>"; echo "</tr>\n"; } echo "</table>"; if(isset($_POST['back'])) {header("location:admin.php");} if(isset($_POST['sub_update'])) { $text = $_POST["name1"]; mysql_query("INSERT INTO serv (password) VALUES ('$text') "); } ?> <body> <form method="post" action=""> <input type="Submit" name="sub_update" value="Ενημέρωση Αλλαγών"style="height:6em; width:16em; font-size:150%;"> <form method="post" action=""> <input type="Submit" name="back" value="Back"style="height:6em; width:16em; font-size:150%;"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/254451-mysql-edit/ Share on other sites More sharing options...
AyKay47 Posted January 6, 2012 Share Posted January 6, 2012 few things here, **in loop** 1. why do you have multiple forms in a loop? that's a no no 2. why do you have forms at all, it looks like you simply want to display the mysql data in a text field, so just have the input without the field since you are not submitting any data to the server. **in body** 1. again, you have multiple forms, when only one is needed. 2. if you are trying to get the input from "name1", you are going about it in the wrong way, encase your entire code in a form, starting the form just before the loop, and check the values when "sub_update" is clicked, as you have. Quote Link to comment https://forums.phpfreaks.com/topic/254451-mysql-edit/#findComment-1304675 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.