Results 1 to 9 of 9

Thread: Displaying and changing info

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    South Wales (UK)
    Posts
    83

    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++;
        }

  2. #2
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    South Wales (UK)
    Posts
    83
    I figured it might be something to do with that. Is there a way of doing what I want in php then?

  4. #4
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    you are doing it. just make those line in php and it should work

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    South Wales (UK)
    Posts
    83
    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?

  6. #6
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    well not realy. al you had to do is this

    PHP Code:
    echo"<SELECT name=\"Status[$i]\" onChange=\"form.submit();\"> 
    that is all.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    South Wales (UK)
    Posts
    83
    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++;
        }
    ?>

  8. #8
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    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

  9. #9
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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
  •  



Click Here to Expand Forum to Full Width