Jump to content

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


MachineGamer

Recommended Posts

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

echo "<td>{$rows['tp']}<a href='edittd.php?edit={$rows['Nom_Matiere']}&number={$rows['Numero']}'> insirer <a></td>";

and when i click on insert they lead me to this page (line of 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 WHERE `Matricule`=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')
}
?>
<form action="instd.php" method="POST">
TD: <input type="text" name="Td" value="<?php echo $rows['Td'];?>"><br>
<input type="hidden" name="Matricule" value="<?php echo $rows[0];?>">
<input type="submit" value="insert">

</form>

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

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

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

{$rows['Nom_Matiere']}&number={$rows['Numero']}

thanks in advance !

 

Link to comment
Share on other sites

You are just on the wrong track here. The way to solve this problem is through a combination of javascript and dynamic form manipulation. One popular path these days would be to start off with a javascript library or framework like jquery.

 

A good book could be written just on the issues with this task. There are whole tutorial series out there that could probably help you.

 

Instead I'm just going to point you to http://www.trirand.net/demo/php/jqgrid/

 

Look at the Add/Edit/Delete Rows section, and run the demos. This is no doubt the functionality you want. I'm sure you'll save a lot of time for yourself as this particular grid comes with a php library that automates the output of javascript with php via a php wrapper library.

Link to comment
Share on other sites

thanks for the reply admin ,but my problem is that i already start working with php and i've never used a javascript or jquery ,and i don't have time to start learning again ,it's for my final project in university and i only have 1 week or less that's why i asking and i hope that i get the answer thanks for your reply !

Link to comment
Share on other sites

If you think the solution is to have an end user type multiple lines of data into one input item, your teacher is not going to reward you.

 

If it is too much to actually get this working in a standard way, then I'd advise you not to worry about the current work flow you have. You are not making things better trying to hack together something that absolutely nobody would do in the real world of web development.

 

Just stick with your current flow, as at least it's logical and fits within the standard paradigm even if it might be a little clunky for people doing repetitive data entry.

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.