PHP Gurus: A Little Help?

Discussion in 'OT Technology' started by 20Deep, Apr 17, 2006.

  1. 20Deep

    20Deep You never with Wenger

    Joined:
    Jul 18, 2001
    Messages:
    107,902
    Likes Received:
    53
    If I have a drop down list on a form that looks like this :

    Code:
    Select a Customer (Customer Number, Customer Last Name, Customer First)
    Name:
    <select name="varcustomer")
    <?
    
         while ($myrow=mysql_fetch_row($resultCustomer))
         {
            echo "<option value=$myrow[0]> $myrow[0], $myrow[1],
            $myrow[2] </option>";
         }
    ?>
    </select>
    
    That means that the $myrow[0] value will be passed as the variable and $myrow[0], $myrow[1], and $myrow[2] will all be displayed as one selection in the drop down list correct? This should work I think but it isnt :hs:
    Anyone have any input?
     
  2. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    Just to clarify, there is no such thing as a php guru. They are php addicts.
     
  3. Shibboleth

    Shibboleth teh mad Plato skillz

    Joined:
    Sep 29, 2004
    Messages:
    1,769
    Likes Received:
    0
    while ($myrow=mysql_fetch_row($resultCustomer)) is probaly failing.
    Check to see if mysql is connected and that $resultCustomer is valid
     
  4. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,921
    Likes Received:
    10
    Location:
    Los Angeles
    You have a typo. Your second line of code should read:
    PHP:
    <select name="varcustomer">
     
  5. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    There is a PHP debugger, isn't there?
     
  6. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    Well, if the error here was just that typo, a PHP debugger wouldn't catch it, since the typo is in the HTML.
     
  7. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    But I would expect a good IDE to catch the HTML error too, as Eclipse does when I fool with Javascript.
     
  8. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,921
    Likes Received:
    10
    Location:
    Los Angeles
    Would be difficult to do so since everyone seems to write half-assed HTML anyway. :hs:
     
  9. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    Well, what I'm getting at is that if he used a good IDE, like Eclipse with the web tools thing, then it would have screamed at the error. So, I'm saying: use an IDE and you won't have these problems.
     
  10. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    I would certainly not consider Eclipse to be a good editor....
     
  11. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    Well thats silly. Eclipse is the best IDE around. Whats your problem with it?

    It doesn't really matter what he uses... he should be using SOME IDE that can check his HTML and PHP for errors as he writes them. Eclipse can do that. If another IDE you like better can, then recommend it.
     
  12. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    Yeah, the validator would have caught it too.
     
  13. Shibboleth

    Shibboleth teh mad Plato skillz

    Joined:
    Sep 29, 2004
    Messages:
    1,769
    Likes Received:
    0
    eclipse isn't even an editor, so I don't know why you say this.
     
  14. 20Deep

    20Deep You never with Wenger

    Joined:
    Jul 18, 2001
    Messages:
    107,902
    Likes Received:
    53
    Good catch but that wasn't it :hs:
    Here is the whole section if it helps.
    Code:
    $queryFlight="SELECT FNum, FDestination from FLIGHT";
    $resultFlight=mysql_query($queryFlight);
    
    $queryCustomer="SELECT CNum, CLName, CFName from CUSTOMER";
    $resultCustomer=mysql_query($queryCustomer);
    ?>
    
    <form method=post action="Confirmation.php">
    
    Select a Customer (Customer Number, Customer Last Name, Customer First)
    Name:
    <select name="varcustomer">
    <?
    
         while ($myrow=mysql_fetch_row($resultCustomer))
         {
            echo "<option value=$myrow[0]>$myrow[0], $myrow[1],
            $myrow[2]</option>";
         }
    ?>
    </select>
    
    <br><br>
    
    Select a Flight (Flight Number, Destination):
    <select name="varflight">
    <?
    
         while ($myrow=mysql_fetch_row($resultFlight))
         {
            echo "<option value=$myrow[0]>$myrow[0], $myrow[1]</option>";
         }
    
     ?>
    </select>
    <br><br>
    Select the Date for the Reservation (mm-dd-yyyy):
    <input name="vardate">
    <br><br>
    <input type=submit value="Enter Reservation Info">
    </form>
    
     
  15. 20Deep

    20Deep You never with Wenger

    Joined:
    Jul 18, 2001
    Messages:
    107,902
    Likes Received:
    53
    This is the code on the executing php page.
    Code:
    <?
    
    trim($varcustomer);
    $varcustomer=addslashes($varcustomer);
    trim($varflight);
    $varflight=addslashes($varflight);
    trim($vardate);
    $vardate=addslashes($vardate);
    
    mysql_connect("****", "****", "****");
    mysql_select_db("****");
    
    $query="insert into CFSCHEDULE(CNum, FNum, CFDate)
    values('%".$varcustomer."%', '%".$varflight."%', '%".$vardate."%')";
    
    $result=mysql_query($query);
    
    echo"<center><br>Reservation Successfully Created</center>";
    
    
    ?>
    
     
  16. 20Deep

    20Deep You never with Wenger

    Joined:
    Jul 18, 2001
    Messages:
    107,902
    Likes Received:
    53
    I figured it out :o
    Thanks for the help though guys :wavey:
     
  17. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0

Share This Page