hey guys ......
im trying to insert/ update the marks in marks table(database) of multiple students at one click of button in php ,how can do iit plzzz reply me or send code for it on my gmail: <Do not solicit for help by email> plz help out me
thank you in advance

Or, to put it another way: do my homework for me as I'm too lazy to bother doing it myself.

Seriously brother, you need to show us what effort you have made, how far you've got with your code and where you have got stuck. Then, and only then, can we help you.

//file1

<html>
<body>
<form action="new.php" method="post">
<table border=1>

<?php

        include("connection.php");

        $result=mysql_query("SELECT * FROM marks");
        echo "<tr align='center'>";
            echo "<td>id</td>";
            echo "<td>name</td>";
            echo "<td>sub1</td>";

            echo "</tr>";

        while($test = mysql_fetch_array($result))
        {
            $id = $test['id'];  

            echo "<tr align='center'>"; 
            echo"<td><font color='black'>" .$test['id']."</font></td>";
            echo"<td><font color='black'>" .$test['name']."</font></td>";
            echo"<td><font color='black'>" .$test['sub1']."</font></td>";
            echo"<td><input type='text' name='change'/></td>";

            echo "</tr>";

        }

        mysql_close($connection);
        ?>
        </table>
     <input type="Submit" name="Submit" value="Submit"/>
        </body>
        </html>

        //file 2

/*
<?php
include"connection.php";
if(isset($_POST['Submit']))

$id;
$result=mysql_query("SELECT * FROM marks");
while($test = mysql_fetch_array($result))
        {
            $id = $test['id'];  
        }

$query=mysql_query("SELECT COUNT(id) FROM marks");
echo $query;

while($id<=$query)

$value=$_GET['change'];

    mysql_query("UPDATE marks SET sub1 ='$value' where name='jailani'")
            or die(mysql_error()); 

echo "Saved!";

?>

*/

see it and suggest me that where im going wrong in this

//file 1
<html>
<body>
<form action="chaya_mam1.php" method="post">
<table border=1>

<?php

            include("connection.php");

            $result=mysql_query("SELECT * FROM marks");
            echo "<tr align='center'>";
                echo "<td>id</td>";
                echo "<td>name</td>";
                echo "<td>sub1</td>";

                echo "</tr>";

            while($test = mysql_fetch_array($result))
            {
                $id = $test['id'];  

                echo "<tr align='center'>"; 
                echo"<td><font color='black'>" .$test['id']."</font></td>";
                echo"<td><font color='black'>" .$test['name']."</font></td>";
                echo"<td><font color='black'>" .$test['sub1']."</font></td>";
                echo"<td><input type='text' name='change'/></td>";

                echo "</tr>";

            }

            mysql_close($connection);
            ?>
            </table>
         <input type="Submit" name="Submit" value="Submit"/>
            </body>
            </html>

            //file2

            <?php
include"connection.php";
if(isset($_POST['Submit']))
{

    $id =$_REQUEST['id'];

$value=$_GET['change'];

        mysql_query("UPDATE marks SET sub1 ='$value' where name='$id'")
                or die(mysql_error()); 
    echo "Saved!";
header("Location: chaya_mam.php");  
}
?>

sorry see this one

sorry to disturb u but , im not able to see ur reply where i can find them

actually this is first time for me that im discussing online

Hi Jailani,

in your code you are using:

$value = $_GET['change'];

which will not work if the form set the method to POST:

<form method="post">

if you perform a POST request then you have to use $_POST in the PHP side to access the values of the input fields. You could use $_GET, but only if appending values to the action link of the form tag, for example:

<form method="post" action="script.php?id=123">

Also, you are trying to access the id, like this:

$id = $_REQUEST['id'];

I suppose you want to get it from this line:

echo"<td><font color='black'>" .$test['id']."</font></td>";

It will not work, unless you do not add an input field like this:

<input type="hidden" name="id" value="<?php echo $test['id']; ?>">

This is more correct, but you are also looping the array from the query, so you are going to create a group of rows, in the HTML, each with:

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

In this case, since you are not submitting $_POST['change'] as an array and since this is a text type, you will apply only the last one in the list:

<tr>
    <td><input type='text' name='change'/>
<tr>
    <td><input type='text' name='change'/>
<tr>
    <td><input type='text' name='change'/> <-- only this will be applied

So the input name should look like more name='change[]':

<tr>
    <td><input type='text' name='change[]'>
<tr>
    <td><input type='text' name='change[]'>

Even by applying this your update query will still not work, because you have to loop the $_POST['change'] and the other fields values.

This post may help you:

it applies to <select> tags, but it works almost the same for text input tags.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.