|
-
May 19th, 2003, 06:36 AM
#1
Thread Starter
Lively Member
Displaying and changing info
What I'm trying to do with the code below is as follows: I've already selected info
from an access dbase and I am displaying it on the web page. I want the user to be able
to change the status via a drop down list, hense the SELECT part. When the status is
changed and the form.submit is executed, the value I changed to is put back to the original
value which I don't want to happen.
I know I could take out the form.submit bit but depending on the status (eg. (L) Lost) I
want another drop down list to dynamically appear next to the status with the reasons in.
I haven't coded that yet, one thing at a time at the moment.
Am I on the right track? Could I do something else in the onChange part? My aim is to
insert this info into a temp table (HitlistTemp) for future use.
I'm fairly new to web development and php so be gentle.
PHP Code:
$count = 0;
$i = 0;
while ( odbc_fetch_into($result, $row) != False )
{
$count++;
if (!IsSet($Status[$i]) || ($Status[$i] <> "N" || $Status[$i] <> "L" || $Status[$i] <> "O" || $Status[$i] <> "T") )
$Status[$i] = $row[5];
echo "<TR bgcolor=$Col>\n";
echo "<TD><A href=\"fd_form.php?HitlistID=".$row[3]."&action=edit&Key=".$Key."&lMonth=".$lMonth."&lYear=".$lYear."\">".$row[2]."</A></TD>\n";
echo "<TD align=\"right\">".number_format($row[4],2)."</TD>\n";
echo "<TD align=\"center\">$row[5]</TD>\n";
?>
<TD>
<SELECT name="Status[$i]" onChange="form.submit();">
<?php
$result3 = odbc_do ($con, "SELECT * FROM HitlistStatusCodes");
while (odbc_fetch_into($result3, $row1) != False)
{
echo "\t\t<OPTION value=\"".$row1[0]."\"";
if ($Status[$i] == $row1[0])
echo " SELECTED";
echo ">".$row1[0]."</OPTION>\n";
//echo ">".$Status[$i]."</OPTION>\n";
}
?>
</SELECT>
</TD>
<?php
echo "</TR>\n";
$HitID[$i] = $row[3];
$query1 = "INSERT INTO HitlistTemp (HitID , Status) VALUES ( $HitID , '$Status[$i]' ) ";
//odbc_do ($con, $query1);
$i++;
}
-
May 19th, 2003, 05:43 PM
#2
Frenzied Member
well for 1 I see this
?>
<TD>
<SELECT name="Status[$i]" onChange="form.submit();">
<?php
you have a variable in there whn you are not in php mode.
"Status[$i]"
tha twon't work since you got out of php mode.
-
May 21st, 2003, 04:30 AM
#3
Thread Starter
Lively Member
I figured it might be something to do with that. Is there a way of doing what I want in php then?
-
May 21st, 2003, 07:46 AM
#4
Frenzied Member
you are doing it. just make those line in php and it should work
-
May 21st, 2003, 12:30 PM
#5
Thread Starter
Lively Member
I changed the following:
Code:
<SELECT name="Status[$i]" onChange="form.submit();">
to
PHP Code:
<?php
echo "<SELECT name=\""."Status"."[".$i."]"."\"";
echo " onChange=\""."form"."."."submit"."(".")".";"."\"";
echo ">"."\n";
?>
but the same thing is happening, is my code correct? Is this what you were on about?
-
May 21st, 2003, 03:11 PM
#6
Frenzied Member
well not realy. al you had to do is this
PHP Code:
echo"<SELECT name=\"Status[$i]\" onChange=\"form.submit();\">
that is all.
-
May 22nd, 2003, 05:10 AM
#7
Thread Starter
Lively Member
Sorry about this, but still no joy i'm afraid. I've posted the entire section below,
maybe i'm missing something.
The 'if ( !IsSet($Status[$i]) and .....' statement seems to run every time a new
status is selected. It's as if the array elements in $Status are not holding
their values?
PHP Code:
<?php
// List anything in the current Hitlist table
$query = "SELECT Month, Year, ProjectName, HitlistID, TotalValue, Status FROM Hitlist ";
$query = $query."WHERE Hitlist.Month=$lMonth AND Hitlist.Year=$lYear AND Hitlist.UserID=$uUserID ";
$result = odbc_do ($con, $query);
//$HitID = "";
//$Status = array();
$Col1 = "#CEE5F7";
$Col2 = "white";
$Col = $Col1;
$count = 0;
$i = 0;
while ( odbc_fetch_into($result, $row) != False )
{
$count++;
if ($count == 1)
{
?>
<TR>
<TD bgcolor="#109BDE"><FONT color="#ffffff">Project</FONT></TD>
<TD bgcolor="#109BDE"><FONT color="#ffffff">Value £</FONT></TD>
<TD bgcolor="#109BDE"><FONT color="#ffffff">Status</FONT></TD>
</TR>
<?php
}
if ($Col == $Col1)
$Col = $Col2;
else
$Col = $Col1;
if ( !IsSet($Status[$i]) and ($Status[$i] <> "N" or $Status[$i] <> "L" or $Status[$i] <> "O" or $Status[$i] <> "T") )
{
$Status[$i] = $row[5];
}
echo "<TR bgcolor=$Col>\n";
echo "<TD><A href=\"fd_form.php?HitlistID=".$row[3]."&action=edit&Key=".$Key."&lMonth=".$lMonth."&lYear=".$lYear."\">".$row[2]."</A></TD>\n";
echo "<TD align=\"right\">".number_format($row[4],2)."</TD>\n";
echo "<TD align=\"center\">$row[5]</TD>\n";
?>
<TD>
<?php
echo "<SELECT name=\"Status[$i]\" onChange=\"form.submit();\">";
?>
<?php
$result3 = odbc_do ($con, "SELECT * FROM HitlistStatusCodes");
while (odbc_fetch_into($result3, $row1) != False)
{
echo "\t\t<OPTION value=\"".$row1[0]."\"";
if ($Status[$i] == $row1[0])
{
echo " SELECTED";
//$Status = $row[5];
}
echo ">".$row1[0]."</OPTION>\n";
//echo ">".$Status[$i]."</OPTION>\n";
}
?>
</SELECT>
</TD>
<?php
echo "</TR>\n";
$i++;
}
?>
-
May 22nd, 2003, 07:33 AM
#8
Conquistador
Originally posted by phpman
well for 1 I see this
?>
<TD>
<SELECT name="Status[$i]" onChange="form.submit();">
<?php
you have a variable in there whn you are not in php mode.
"Status[$i]"
tha twon't work since you got out of php mode.
?>
<TD>
<SELECT name="<? echo Status[$i]; ?>" onChange="form.submit();">
<?php
hth
-
May 22nd, 2003, 11:31 AM
#9
Frenzied Member
PHP Code:
<?php
echo "<SELECT name=\"Status[$i]\" onChange=\"form.submit();\">";
?>
you forgot the $ on the Status.
also da_silvy, what is the difference? I hate doing it that way. but it should still work the other way. all tha tis is another way to do php mode.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|