Update in MySQL retreivng different values
Posted: Fri Jul 25, 2003 6:54 pm
I have a little problem with my Update sequence...really I don't know if this can be done or not. What I need is that you can Edit some values from a displaying table in my form, the thing is that I was only getting the last of the values in my table, I've managed to obtain the first value or the value I want...But how can I make the update to get me all the values from the table...The code is as follows...
Here is where I got my problem.
If I put the 0, I get the values of the first field, If I put a 1, I get the values of the second field and so on... What I want to know is...How can I manage to put the number that follows, i.e., description='$newDesc1' and so on... but in some sort of automatic way...
I know I can use many update sequences, I've done that before, but because I don't know the exact number of fields in my table (Because it changes constantly) there's my problem...
Please..if someone knows how to this I would be very grateful with you...I'm a little desperate...I try to explain myself as much as possible, but as you can see it's a little confusing what I am trying to do, but I know you can give me a hand on this..
Code: Select all
<?php
include ("connect.php"); //This I use to connect to my sql, it works fine..
$short="style='width: 60px;'"; //Just some defined styles for my text
$small="style='width: 90px;'";
$big="style='width: 200px;'";
$strSQL="SELECT * FROM Action_Items WHERE project LIKE '".$project."%' ORDER BY project_status DESC, deadline";
$recordset=$db1->Execute($strSQL); //This is where I get all the fields
$a=0; //Variables for managing the names of the fields
$b=0;
$c=0;
$d=0;
$e=0;
$f=0;
$g=0;
$h=0;
while(!$recordset->EOF)
{
$id=$recordset->fields[0]; //Obtain the Id from the table for later use in the Update...
?>Code: Select all
<?php
if(isset($updtAI)){
$strUpdt="UPDATE Action_Items SET start_date='$newStrtdate0', description='$newDesc0', comments='$newCmms0', action_taken='$newAct0', responsible='$newResp0', project_status='$newProjSt0', deadline='$newDln0', delivery_date='$newDlvr0' WHERE project='$project' and id='$id'";
$recordset=$db1->Execute($strUpdt);
echo "Sentencia: ".$strUpdt."<br>";
}
?>I know I can use many update sequences, I've done that before, but because I don't know the exact number of fields in my table (Because it changes constantly) there's my problem...
Code: Select all
<?php
//Here is where I display my table, as you can see I've assigned names to each field so I can do my Update and know wich value I am getting... ...[/b]
$class_row="td_sow";
echo "<td style="text-align: left;"><img src='$tmpColor'></td>";
echo "<td style="text-align: left; font-size: 7pt;"><nobr>".$recordset->fields[1]."</nobr></td>";
echo "<td $short><input class='td_col' style="background-color:#ffffff;" $short value='".$strtdate."' name='newStrtdate$a' $dis></td>";
echo "<td $short><input class='td_col' style="background-color:#ffffff;" $short value='".$recordset->fields[7]."' name='newProjSt$b' $dis></td>";
echo "<td><textarea class='td_col' style="width: 180px; background-color:#ffffff; text-align: left;" name='newDesc$c' $dis>".$recordset->fields[3]."</textarea></td>";
echo "<td><textarea class='td_col' style="width: 180px; background-color:#ffffff; text-align: left;" name='newCmms$d' $dis>".$recordset->fields[4]."</textarea></td>";
echo "<td><input class='td_col' style="background-color:#ffffff;" value='".$recordset->fields[6]."' name='newResp$e' $dis></td>";
echo "<td $short><input class='td_col' style="background-color:#ffffff;" $short value='".$deadln."' name='newDln$f' $dis></td>";
echo "<td $short><input class='td_col' style="background-color:#ffffff;" $short value='".$dlvr."' name='newDlvr$g'$dis></td>";
echo "<td><textarea class='td_col' style="width: 180px; background-color:#ffffff; text-align: left;" name='newAct$h' $dis>".$recordset->fields[5]."</textarea></td>";
echo "</tr>";
$a=$a+1; //These variables are to manage the names of the fields I am displaying, as you can se above.... So the variables have different names and can be managed...
$b=$b+1;
$c=$c+1;
$d=$d+1;
$e=$e+1;
$f=$f+1;
$g=$g+1;
$h=$h+1;
$recordset->MoveNext();
}
?>