how to make an array of html to insert Values into database

hey i am stuck i want some help in my script ,in the first time i was using this line of code:

[php]echo "

{$rows[‘tp’]}<a href=‘edittd.php?edit={$rows[‘Nom_Matiere’]}&number={$rows[‘Numero’]}’> insirer ";
[/php]
and when i click on insert they lead me to this page (line of code):

[code]<?php
include_once(‘base.php’);
echo mysql_error();
if(isset($_GET[‘insert’])){
$Matricule = $_GET[‘insert’];
$Id_Matiere = $_GET[‘number’];
$res = mysql_query(“select * from evaluation WHERE Matricule = ‘$Matricule’”);
$rows = mysql_fetch_array($res);
}
echo mysql_error();
if(isset($_POST[‘Td’])){
$Matricule = $_POST[‘Matricule’];
$Id_Matiere = $_GET[‘number’];
$Td = mysql_real_escape_string($_POST[‘Td’]);
$sql = “UPDATE evaluation SET Td = ‘$Td’ WHERE Matricule = ‘$Matricule’”;
//$sql = “UPDATE evaluation SET Td=15 WHEREMatricule`=1”;
$res = mysql_query($sql) or die("Could not update ".mysql_error());

        echo "<meta http-equiv='refresh' content='0;url=edittd.php'>";
echo "You/'ve Successfully insert the Td Note Thanks.";
//INSERT INTO `b_database`.`evaluation` (`Matricule`, `Id_Matiere`, `Td`, `Tp`, `Exam`, `Ratrapage`) VALUES ('13458', '14', '3.25', '0', '0', '0')
}

?>

TD:
[/code]

so i will be able to update mu values into my database, but it’s too slow for any user to insert data if i have a lot of values in my array do the user have to click on every insert button to lead him to another page and update the value so , i was thinking to change my code of line to this :

echo "<td><input type='text'> </td>";

so they can insert a lot of values in one line and click on one submit button and all the values get stored into my database ,so please how can i include the 1st line of code echo "<td>{$rows['tp']}<a href='edittd.php?edit={$rows['Nom_Matiere']}&number={$rows['Numero']}'> insirer <a></td>";

to this input type

[php]echo "

";[/php]

and the textbox recognize every row like he did on insirer :

[php]{$rows[‘Nom_Matiere’]}&number={$rows[‘Numero’]}[/php]

thanks in advance !

I think you are confused about forms and databases. First, let’s describe an entry form.

A form is a list of entries on ONE page of HTML.
It can contain one item such as a user name or password.
Or, it can contain hundreds of input fields.
Normally a form has only ONE submit button. (Although others can be used if you wish.)

Now, to enter a value into a database, you would use a form with the input field in place, like:

Or...

Now, as you see one submit button will work for large numbers of fields.
The only catch is that each field must have a unique name so you can grab their values.

Here is a link to explain forms further: http://www.w3schools.com/php/php_forms.asp
Normally, you do not enter one field at a time. You update the database with ALL of the fields.
Your first line shows you are using some sort of “Template”.
Line 15 in the second listing shows you are updating one item, “Td”.
You can use multiple SET commands inside an UPDATE query. Here is a link that explains:
http://www.w3schools.com/php/php_mysql_update.asp example updates two fields

Hopefully, that is what you were looking for. Hope it helps…

Sponsor our Newsletter | Privacy Policy | Terms of Service