Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Populate form form MySQL data

  1. #1
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Populate form form MySQL data

    Hi Folks,

    I am trying to produce a webpage that will show numbers /text in tables on a webpage.

    The data is to be in MySQL database.

    If there is somebody that has already doen this your assitance would be most welocme.

    My knowledge of this process is next to zero.

    I look forward to any replys, examples, help.

    Kind Regard
    ROb

  2. #2
    Join Date
    Mar 2009
    Location
    NJ, USA
    Posts
    32
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Are you looking to fill a form with your data or fill your data with a form?
    Will you be using PHP to contact your DB? Do you have PHPMyAdmin?

    http://www.w3schools.com/php/php_mysql_intro.asp

    This site has some good guides. To call data from the DB you can use the SELECT function... although I am stuck on a SELECT function myself.

  3. #3
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Arrow

    Thanks for the speedy reply.

    I have a php forms that will send info to MySQL.

    Once it is there I am trying to create webpages that will populate using data from the MySQL Database and in some instances additional new data directly typed in.

    So to answer your quetion I guess it would be both.

    Thanks for the link I will have a look at it.

    I have managed to get my page to look something like this www.gnjgf.co.za/GolfMembers.html

    Regards
    Rob

  4. #4
    Join Date
    Mar 2009
    Location
    Chennai, India
    Posts
    77
    Thanks
    16
    Thanked 7 Times in 6 Posts

    Default

    Hi, Right now the table displays the php variables and not the actual values...

    I think the data has been inserted to database with php variables and that is why it shows the variable names there...

    I have just used a part of variables as example to show how it should be inserted:
    Code:
    $Surname=$_POST['Surname'];
    $Name=$_POST['Name'];
    
    $query_string = "INSERT INTO the_table_name (field_surname, field_name)  VALUES ('$Surname', '$Name') ";
    
    $query = mysql_query($query_string);
    
    if(!$query){
    die(mysql_error());
    }
    else
    {
    echo "Entries successfully updated";
    }
    Make sure that you change the table_name into the actual table name in your database and field_surname, field_name to the respective field names in the table...


    Also, the table in the page is too long... Make sure that you actually split it into several rows instead of 1 row

  5. The Following 2 Users Say Thank You to borris83 For This Useful Post:

    n1tr0b (04-15-2009),Rob (SA) (04-11-2009)

  6. #5
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    I have made some changes and cosmetically it is already looking better.

    I will sort out the database side and see if I can get the desired result.

    Regards
    Rob

  7. #6
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    Hi

    Because of the way that PHP immediately executes I use HTML forms to collect the data/amendments and then have a form action="somecode.php" that updates the MYSQL database.

    I have recently written some code that takes all the selected records from the database, stores it in a PHP array and converts that array into a javascript array.

    Using this array I can display all the records and fields, using array.split, or I can retrieve an individual record, display its current values, for amendment, and the updates the MYSQL table with the changes.

    If this is of interest then let me know

  8. #7
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    Thanks for this reply and it sounds very interesting.

    As I am very new to the whole programming side of html and php I would love to consider all my options and learn more about what you have done.

    Kind Regards
    Rob

  9. #8
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    I hav sent you a PM, check your inbox

  10. #9
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    Thanks for the info.

    I will have a look at the PM -and give feed back

    Regards
    Rob
    Last edited by Rob (SA); 04-16-2009 at 03:35 PM.

  11. #10
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi Folks,

    I have managed to get my page www.gnjgf.co.za/GolfMembers.html to look ok yet need to find out if this information below is correct will populate the page ?


    <!--------------------------------------------------------------------->
    <! THIS SECTION CHANGES WHAT THE TABLE LOOKS LIKE >
    <!--------------------------------------------------------------------->

    <table border=3 width="35%" cellspacing=0 style="background-color:#FFFFFF;">

    <!--------------------------------------------------------------------->
    <!MAKE CHANGES TO THIS SECTION IF YOU WANT THE PAGE HEADING/s TO CHANGE>
    <!--------------------------------------------------------------------->

    <caption>
    <font style>&nbsp</font>
    </caption>
    <caption>
    <b><font style="font-size:20px" color="#00008B" face="Arial">
    GAUTENG NORTH JUNIOR GOLF FOUNDATION</font><b>
    </caption>
    <caption>
    <font style="font-size:16px" color="#00008B" face="Arial">
    MEMBERSHIP LIST</font>
    </caption>
    <caption>
    <font style>&nbsp</font>
    </caption>

    <!--------------------------------------------------------------------->
    <! CHANGE COLUMN HEADING/s OF THE TABLE HERE >
    <!--------------------------------------------------------------------->

    <tr>
    <th><td align="center" valign="middle" width="100" height="30"><b><font style="font-size:10px" color="#00008B" face="Arial">SURNAME</font></b></td></th>
    <th><td align="center" valign="middle" width="100" height="30"><b><font style="font-size:10px" color="#00008B" face="Arial">NAME</font></b></td></th>
    <th><td align="center" valign="middle" width="100" height="30"><b><font style="font-size:10px" color="#00008B" face="Arial">DATE OF BIRTH</font></b></td></th>
    <th><td align="center" valign="middle" width="100" height="30"><b><font style="font-size:10px" color="#00008B" face="Arial">IDENTITY NO.</font></b></td></th>
    <th><td align="center" valign="middle" width="100" height="30"><b><font style="font-size:10px" color="#00008B" face="Arial">CELL PHONE</font></b></td></th>
    <th><td align="center" valign="middle" width="100" height="30"><b><font style="font-size:10px" color="#00008B" face="Arial">HOME PHONE</font></b></td></th>
    <th><td align="center" valign="middle" width="100" height="30"><b><font style="font-size:10px" color="#00008B" face="Arial">WORK PHONE</font></b></td></th>
    <th><td align="center" valign="middle" width="100" height="30"><b><font style="font-size:10px" color="#00008B" face="Arial">&nbsp &nbsp FAX &nbsp &nbsp</font></b></td></th>
    <th><td align="center" valign="middle" width="100" height="30"><b><font style="font-size:10px" color="#00008B" face="Arial">E-MAIL</font></b></td></th>
    </tr>

    <!--------------------------------------------------------------------->
    <! THIS SECTION IS WHAT CALLS IT FROM THE DATABASE TABLE >
    <!--------------------------------------------------------------------->

    <?
    $MySQLhost="local****";
    $MySQLusername="******h";
    $MySQLpassword="f********n";
    $MySQLdatabase="egh***_members";
    $dbconnect = mysql_connect($MySQLhost,$MySQLusername,$MySQLpass word)
    or die ("Could not connect to mysql because ".mysql_error());
    mysql_select_db($MySQLdatabase)
    or die ("Could not select database because ".mysql_error());

    $Surname=.$_POST['Surname'].;
    $Name=.$_POST['Name'].;
    $Date of Birth=.$_POST['Date_of_Birth'].;
    $Identity Number=.$_POST['Identity_No'].;
    $Cell_Phone=.$_POST['Cell_Phone'].;
    $Home_Phone=.$_POST['Home_phone'].;
    $Work Phone=.$_POST['Work_phone'].;
    $Fax=.$_POST['Fax'].;
    $Email=.$_POST['Email'];
    $query = mysql_query("INSERT INTO MEMBERS (Surname, Name, Date_of_Birth, Identity_No, Cell_Phone, Home_phone, Work_phone, Fax, email)
    VALUES
    ('$Surname','$Name','$Date_of_Birth','$Identity_No ','$Cell_Phone', '$Home_phone','$Work_phone','$Fax','$email')", $dbconnect);
    exit;
    }
    ?>

    Regards
    Rob

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
  •