Where do I start

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
User avatar
php-forum Active User
php-forum Active User
Posts: 365
Joined: Tue Feb 22, 2011 8:19 am
Location: Canada

Sat Oct 18, 2014 5:13 pm

The easiest way is to set up a mysql database. Without knowing more about what you want to do and why, I can't tell you the exact structure you'd use, but you could just use one table like this:

TABLE: id, box1, box2, box3

When the form is submitted, you'd get the $_POST['box1'] etc. and insert them into the database using something like this (with mysqli or PDO). Obviously this isn't all you'd need, but it should get you started.

Code: Select all

$box1 = $_POST['box1'];
$box2 = $_POST['box2'];
$box3 = $_POST['box3'];

$insertQuery = "INSERT INTO table (box1, box2, box3) VALUES ('$box1', '$box2', '$box3')";

if (mysqli_query($link, insertQuery) === TRUE) 
    echo "Result stored";
To read back the database, you'd just want a SELECT query:

Code: Select all

$selectQuery = "SELECT box1, box2, box3 FROM table";
$result = mysqli_query($link, $selectQuery);

while ($row = mysqli_fetch_array($result))
echo $row[0]."<br/>";
echo $row[1]."<br/>";
echo $row[2]."<br/>";

Post Reply