SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 35

Thread: form help

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    USA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form help

    Hello, everyone i'm new to php and I need to link this form
    http://nbrec.com/salsenrollment.html
    to my MySQL DB

    CREATE TABLE RegistrationTBL (
    ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    ENRLL_Fname VARCHAR (20),
    ENRLL_Lname VARCHAR (20),
    ENRLL_Email VARCHAR (25),
    ENRLL_Sex char (2),
    ENRLL_Age int (3),
    ENRLL_Address VARCHAR (20),
    ENRLL_City VARCHAR (20),
    ENRLL_Zip char (5),
    ENRLL_State char (2) default ' nj ',
    ENRLL_Phnum char (11),
    ENRLL_Tmname VARCHAR (20),
    ENRLL_CoachName VARCHAR (20),
    ENRLL_Comment text,
    ENRLL_Date Date Not Null);

    but i seem to be unable to get it right.... can anyone help we w/ this form......

    thanks

  2. #2
    Non-Member hyperimage's Avatar
    Join Date
    Dec 2003
    Location
    Croatia
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    hi

    PHP Code:
    <?php
    $dbhost 
    "host";
    $dbuser "user";
    $dbpass "password";
    $dbname "database name";

    $connect mysql_conenct("$dbhost""$dbuser""$dbpass") or die(mysql_error()); 
    mysql_select_db("$dbname"$connect) or die(mysql_error()); 

    $ret "insert into your_table values('', '$your_table_fields')";
          
    $resultat mysql_query($ret);
        
    mysql_close($connect);
    ?>
    the first field is allways empty couse it is the "id" with auto increment attribute!
    cya

  3. #3
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need an INTO after INSERT there.

  4. #4
    Non-Member hyperimage's Avatar
    Join Date
    Dec 2003
    Location
    Croatia
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    :)

    Quote Originally Posted by Jump
    You need an INTO after INSERT there.
    i wanna be speedy and at finish i messed up
    thanx

  5. #5
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Capitalizing the SQL makes it easier to differentiate from the values.
    PHP Code:
    $ret "INSERT INTO your_table VALUES('NULL', '$your_table_fields')"

  6. #6
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    USA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanxs i'll try to get this working and let you know how i did...

  7. #7
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    USA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is it me or you're not reading the input from the text boxes?

    Sorry like i said i'm new to php

    thanx

  8. #8

    Join Date
    Oct 2003
    Location
    €uroLand
    Posts
    1,340
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You just need to map the particular input fields from the _POST array to the appropriate positions in your insert statement.

    PHP Code:
    mysql_query('INSERT INTO your_table VALUES (NULL, "'.$_POST['name'].'", "'.$_POST['lname'].'", "'.$_POST['email'].'", .......)'

  9. #9
    Non-Member hyperimage's Avatar
    Join Date
    Dec 2003
    Location
    Croatia
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    try this...it should work!!!

    PHP Code:
    <?php 
    $dbhost 
    "125.0.0.1"
    $dbuser "alope"
    $dbpass "mblack942"
    $dbname "nbrec_com_-_db"

    $connect mysql_conenct("$dbhost""$dbuser""$dbpass") or die(mysql_error()); 
    mysql_select_db("$dbname"$connect) or die(mysql_error()); 
    ?>
    <html>
    <body>
    <table>
    <?php
    $question
    mysql_query("select ENRLL_Fname, ENRLL_Lname, ENRLL_Email from RegistrationTBL order by 'id' desc");
    $rowmysql_fetch_row($question);
    echo 
    "<tr><td> First Name </td><td> Last Name </td><td>Email</td><td> Sex </td><td> Age </td><td> Address </td><td> City </td><td> Zip </td><td> State </td><td> Phone # </td><td> Team Name </td><td> Coach Name </td></tr><tr><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td></tr>";
    mysql_free_result($question);
    ?>
    </table></body></html>

  10. #10
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    USA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    didn't work... i'm getting an error on line 37
    http://www.nbrec.com/R_output2.php

    print "</html>";

  11. #11
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd format the table otherwise you'll leave the (visible) page with the address items.
    And i'd use either one echo/print instead of that many for each line or use the heredoc syntax.
    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.

  12. #12
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    USA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey frezno pls feel free jump in and help..
    thanks..

  13. #13
    Non-Member hyperimage's Avatar
    Join Date
    Dec 2003
    Location
    Croatia
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    finished

    thats it

  14. #14
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ghost
    didn't work... i'm getting an error on line 37
    There's a typo (conenct) in the example.
    And i wouldn't use quotes for the variables:

    PHP Code:
    $connect mysql_connect($dbhost$dbuser$dbpass) or die(mysql_error()); 
    mysql_select_db($dbname$connect) or die(mysql_error()); 
    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.

  15. #15
    Non-Member hyperimage's Avatar
    Join Date
    Dec 2003
    Location
    Croatia
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    this script have to work 300%

    PHP Code:
    <?php 
    $dbhost 
    "125.0.0.1"
    $dbuser "alope"
    $dbpass "mblack942"
    $dbname "nbrec_com_-_db"

    $connect mysql_conenct("$dbhost""$dbuser""$dbpass") or die(mysql_error()); 
    mysql_select_db("$dbname"$connect) or die(mysql_error()); 
    ?> 
    <html> 
    <body> 
    <table> 
    <?php 
    $question
    mysql_query("select ENRLL_Fname, ENRLL_Lname, ENRLL_Email from RegistrationTBL order by 'id' desc"); 
    $rowmysql_fetch_row($question); 
    echo 
    "<tr><td> First Name </td><td> Last Name </td><td>Email</td><td> Sex </td><td> Age </td><td> Address </td><td> City </td><td> Zip </td><td> State </td><td> Phone # </td><td> Team Name </td><td> Coach Name </td></tr><tr><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td></tr>"
    mysql_free_result($question); 
    ?> 
    </table></body></html>
    no parse error here or something

  16. #16
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    USA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok...part of it is working now.... here's the code....


    <?php
    $dbhost = "125.0.0.1";
    $dbuser = "alop";
    $dbpass = "mblackxxx";
    $dbname = "nbrec_com_-_db";

    $connect = mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error());
    mysql_select_db($dbname, $connect) or die(mysql_error());
    ?>
    <html>
    <body>
    <table>
    <?php
    $question= mysql_query("select ENRLL_Fname, ENRLL_Lname, ENRLL_Email from RegistrationTBL order by 'id' desc");
    $row= mysql_fetch_row($question);
    echo "<tr><td> First Name </td><td> Last Name </td><td>Email</td><td> Sex </td><td> Age </td><td> Address </td><td> City </td><td> Zip </td><td> State </td><td> Phone # </td><td> Team Name </td><td> Coach Name </td></tr><tr><td>$row[1];</td><td>$row[2];</td><td>$row[3];</td></tr>";
    mysql_free_result($question);
    ?>
    </table></body></html>

  17. #17
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    for the output, either:

    PHP Code:
    echo "<table>
    <tr><td> First Name </td><td> Last Name </td></tr>
    <tr><td>Email</td></tr><tr><td> Sex </td></tr><tr><td> Age </td></tr>
    <tr><td> Address </td></tr>
    <tr><td> City </td><td> Zip </td><td> State </td></tr>
    <tr><td> Phone # </td></tr>
    <tr><td> Team Name </td></tr><tr><td> Coach Name </td></tr>
    <tr><td>"
    $row[1] ."</td></tr><tr><td>"$row[2] ."</td></tr><tr><td>"$row[3] ."</td></tr>
    </table>"

    or heredoc:
    PHP Code:
    $myTable = <<<EOT
    <table>
    <tr><td> First Name </td><td> Last Name </td></tr>
    <tr><td>Email</td></tr><tr><td> Sex </td></tr><tr><td> Age </td></tr>
    <tr><td> Address </td></tr>
    <tr><td> City </td><td> Zip </td><td> State </td></tr>
    <tr><td> Phone # </td></tr>
    <tr><td> Team Name </td></tr><tr><td> Coach Name </td></tr>
    <tr><td>
    $row[1]</td></tr><tr><td>$row[2]</td></tr><tr><td>$row[3]</td></tr>
    </table>
    EOT;
     
    echo 
    $myTable
    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.

  18. #18
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    USA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is how it looks like, right now. like you can see is not displaying the Fname & since the loop was removed, it only reads the first record..
    http://www.nbrec.com/R_output3.php

  19. #19
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i don't know exactly what you are trying to do:
    Display the content of a database into a form or
    letting someone filling out the form and save the data to the db?
    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.

  20. #20
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    USA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry, you came in the middle of things.... i was first trying to get data into the db....but then i asked hyperimage to help me w/ my code to get data "out" of the db...

    by the way this is how your code looks like
    http://www.nbrec.com/R_outputFrezno.php

    thanks 4 helping

  21. #21
    Non-Member hyperimage's Avatar
    Join Date
    Dec 2003
    Location
    Croatia
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    hehehe

    my script work perfectly hehehehehehe

  22. #22
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, got it.

    so, what you almost have everything you need.

    PHP Code:
    <?php 
    $dbhost 
    "127.0.0.1"
    $dbuser "nbrec"
    $dbpass "mblack942"
    $dbname "nbrec_com_-_db"

    $db mysql_connect($dbhost$dbuser$dbpass) or die(mysql_error()); 
    mysql_select_db($dbname$db) or die(mysql_error()); 

    $sql "SELECT ENRLL_Fname, ENRLL_Lname, ENRLL_Email 
            FROM  RegistrationTBL 
            ORDER BY id DESC"
    ;
     
    $sql_form mysql_query($sql); 
    ?>

    <html><head><title>form test</title></head><body>
    <?php 
    while ($r mysql_fetch_object($sql_form))
    {
        echo 
    '<table>
              <tr><td>First Name: </td><td>'
    $r->ENRLL_Fname .'</td><td>Last Name:</td>'$r->ENRLL_Lname .'</td></tr>
              <tr><td>eMail: </td><td>'
    $r->ENRLL_Email .'</td></tr>
              </table>'
    ;
    }
    ?>
    </body></html>
    just hacked it in, so maybe there's still some quirks in it.
    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.

  23. #23
    Non-Member hyperimage's Avatar
    Join Date
    Dec 2003
    Location
    Croatia
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    hehe

    i have to challenge frezno on script parse

  24. #24
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.

  25. #25
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    USA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    frezno

    sorry, frezon your code gave an error
    http://nbrec.com/alopez/dbresult_f.php

    thanx anyways!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •