Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2008
    Posts
    2

    Red face Unanswered: OK - I give up!!! html to dbase and back to html page!!????

    I thought it would be easier than what I am going through! Admittedly I may be missing a few bricks etc! BUT - I need this sortted ASAP!!

    Can anyone help me please.

    Have web page form.
    Hosting is linux.
    Have PHP and MYSQL on server.
    I use frontpage and have the form ready.
    I want the info split - 1.All info to database
    2.Most info to webpage page display result
    3.Different responses to form will send html output to
    different html display pages.

    And that is that!??

    This has now become extremely urgent - would appreciate urgent responses.

    Regards
    Andy

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Leave your homework project to the last minute, eh?

    Start here http://w3schools.com/php/php_mysql_intro.asp

    Moved to PHP forum
    George
    Home | Blog

  3. #3
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    I'll present a simple example for you (because you're lucky) adapt/expand it as you need:

    myform.html
    Code:
    <html>
    <head>
    </head>
    <body>
    	<form action="process.php" name="myform">
    		<fieldset>
    			<label for="name">Name</label><input type="text" name="name" />
    			<label for="age">Age</label><input type="text" name="age" />
    			<input type="submit" name="submit" value="submit" />
    		</fieldset>
    	</form>
    </body>
    </html>
    process.php
    Code:
    <?php
    
    $redirect = "myform.html";
    
    if($_POST['submit']){
    	$name = $_POST['name'];
    	$age = $_POST['age'];
    
    	// Database connection params
    	$hostname = "localhost";
    	$mysql_user = "<your mysql username here>";
    	$mysql_password = "<your mysql password here";
    	$database = "<your database name here>";
    	
    	// Connect to the database.
    	mysql_connect($hostname,$mysql_user,$mysql_password);
    	
    	// Select the database
    	mysql_select_db($database);
    	
    	// Perform the query.
    	$sql = "INSERT INTO <your table name here>(name,age) VALUES('%s',%d)";
    	$query = sprintf($sql,$name,$age);
    	mysql_query($query);
    	
    	$redirect = "display.html";
    }
    
    header("Location:{$redirect}");
    ?>
    display.html
    Code:
    <?php
    
    // Database connection params
    $hostname = "localhost";
    $mysql_user = "<your mysql username here>";
    $mysql_password = "<your mysql password here";
    $database = "<your database name here>";
    
    // Connect to the database.
    mysql_connect($hostname,$mysql_user,$mysql_password);
    
    // Select the database
    mysql_select_db($database);
    
    // Perform the query.
    $sql = "SELECT name,age FROM <your table name here>";
    $query = sprintf($sql);
    $result = mysql_query($query);
    
    // Initialise dataset.
    $people = array();
    while($row = mysql_fetch_assoc($result)){
    	// Build dataset.
    	$people[] = $row;
    }
    ?>
    
    <html>
    <head>
    <style>
    table, table td {
     border: 1px;
    }
    </style>
    </head>
    <body>
    	<table>
    		<tr><td>Name</td><td>Age</td></tr>
    		<?foreach($people as $person):?>
    		<tr><td><?=$person['name']?></td><td><?=$person['age']?></td></tr>
    		<?endforeach;?>
    	</table>
    </body>
    </html>

  4. #4
    Join Date
    Feb 2008
    Posts
    2
    Quote Originally Posted by georgev
    Leave your homework project to the last minute, eh?

    Start here http://w3schools.com/php/php_mysql_intro.asp

    Moved to PHP forum
    Hmmmmmmm!! Well I gave up, shoved the job on Elance - unidated with responses within an hour - now there's 3 of them to do it!!

    Next time - I won't even bother to burn brain juice!!!!!

    Global can be great - if it works, then great!

    Cheers for response anyway. Think time to stop learning and enjoy my time! Chow

Posting Permissions

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