Jump to content

mysql edit


lioslios

Recommended Posts

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>

 

 

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.