Energizer Bunny
12-07-2009, 07:10 PM
Maybe someone here can help me achieve what i am trying to achieve with database.
I have following problem :
I am using a code similar to this :
do {
while ($row = mssql_fetch_array($var1)) {
echo '<tr><td style="width:80px;border-bottom:thin solid #666666;"><input type="text" value='.$row['user_var1'].' name="var1[]"/></td><td> <input type="text" value='.$row['var2'].' name="var2[]"/>'</td></tr>';
}
} while (mssql_next_result($var1));
Now what I am trying to achieve is modification of database using
$value = $_POST['user_var1'];
$valuexyz = $_POST['user_var2'];
$query= "UPDATE user_db1 SET user_var1 = '$value' WHERE user_var2='$valuexyz' ";
mssql_query($query);
Its not the exact code just trying to provide some idea.
What i am trying to do is have an auto generated form field, with values fetched from database and editable inside the do while loop so multiple rows are generated via database, now i am trying to modify one single row on that auto generated form, but am not able to modify just 1 particular row, var2 is common to all rows or user_var2 and in query you can see that it will update every row where it find user_var2 and not just 1 particular row that i am trying to update.
Any ideas on how to update just 1 single row even though the where clause is such that it consists of various similar entires.
Say for example i am trying to edit someones named "smith" phone number, but there are multiple smith's , and updating one , results in updating every smith's phone numbers.
Smith example http://www.sql-tutorial.net/SQL-UPDATE.asp
look at the bottom, but i want to modify only say one on the top and not the bottom entry.
Thanks i hope there is a solution to this weirdness.
I have following problem :
I am using a code similar to this :
do {
while ($row = mssql_fetch_array($var1)) {
echo '<tr><td style="width:80px;border-bottom:thin solid #666666;"><input type="text" value='.$row['user_var1'].' name="var1[]"/></td><td> <input type="text" value='.$row['var2'].' name="var2[]"/>'</td></tr>';
}
} while (mssql_next_result($var1));
Now what I am trying to achieve is modification of database using
$value = $_POST['user_var1'];
$valuexyz = $_POST['user_var2'];
$query= "UPDATE user_db1 SET user_var1 = '$value' WHERE user_var2='$valuexyz' ";
mssql_query($query);
Its not the exact code just trying to provide some idea.
What i am trying to do is have an auto generated form field, with values fetched from database and editable inside the do while loop so multiple rows are generated via database, now i am trying to modify one single row on that auto generated form, but am not able to modify just 1 particular row, var2 is common to all rows or user_var2 and in query you can see that it will update every row where it find user_var2 and not just 1 particular row that i am trying to update.
Any ideas on how to update just 1 single row even though the where clause is such that it consists of various similar entires.
Say for example i am trying to edit someones named "smith" phone number, but there are multiple smith's , and updating one , results in updating every smith's phone numbers.
Smith example http://www.sql-tutorial.net/SQL-UPDATE.asp
look at the bottom, but i want to modify only say one on the top and not the bottom entry.
Thanks i hope there is a solution to this weirdness.
