Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6024487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:09:45+00:00 2026-05-23T04:09:45+00:00

I’m sorry if this question frustrates anyone … I am truly a beginner to

  • 0

I’m sorry if this question frustrates anyone … I am truly a beginner to PHP + MYSQL but I would love to make some progress on this one!

My Goal:

  1. To create a table that I can view in a web page.
  2. To be able to add data (rows) to this table and still have the data be there the next time the page is loaded.

Step 1: Creating the table

<html>
<body>

<?php

// Conect to MYSQL
$con = mysql_connect("localhost", "My_Username", "My_Password") or die(mysql_error());
echo "Connected to MYSQL </br>";

mysql_select_db("My_Database") or die(mysql_error());
echo "Connected to Database";

// Create a MySQL table in the selected database (called ExampleTable)

$sql = "CREATE TABLE ExampleTable
 (
// Set the primary key (personID)
 personID int NOT NULL AUTO_INCREMENT, 
 PRIMARY KEY(personID),
 ColumnOne varchar(15)
 ColumnTwo varchar(15)
 ColumnThree varChar(30)
 )";

// Execute query
mysql_query($sql,$con);

mysql_query("INSERT INTO ExampleTable(ColumnOne, ColumnTwo, ColumnThree)
VALUES ('Data1', 'Data2', 'Data3')");

mysql_query("INSERT INTO ExampleTable(ColumnOne, ColumnTwo, ColumnThree) 
VALUES ('Data_Data1', 'Data_Data2', 'Data_Data3')");

mysql_close($con);

?>

</body>
</html>

So, I have now created a MYSQL table with two three columns, and two rows of data. How can I get this table to show up on a web page?

Step 2: Saving / Retrieving saved data
Is there some way that I can add data to a table, so that the data will be there permanently? – or is this how it works by default?

For example: Let’s say that I have a form with a button on it. When the button is clicked a new row is added to the table ‘ExampleTable’. The next time the user visits the page the table will be updated with his newly added data.

Thank you very much for any help. I understand that I am a beginner and do not fully understand these topics yet. Any responses will be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:09:46+00:00Added an answer on May 23, 2026 at 4:09 am

    1 – Displaying All Data

    <?php
    
    // Conect to MYSQL
    $con = mysql_connect("localhost", "My_Username", "My_Password") or die(mysql_error());
    echo "Connected to MYSQL </br>";
    
    mysql_select_db("My_Database") or die(mysql_error());
    echo "Connected to Database";
    
    // Get all the data from the "ExampleTable" table
    $result = mysql_query("SELECT * FROM ExampleTable") or die(mysql_error());  
    
    echo "<table border='1'>";
    echo "<tr> <th>ColumnOne</th> <th>CoumnTwo</th> <th>CoumnThree</th> </tr>";
    
    // keeps getting the next row until there are no more to get
    while($row = mysql_fetch_array( $result )) {
    
        // Print out the contents of each row into a table
        echo "<tr><td>"; 
        echo $row['ColumnOne'];
        echo "</td><td>"; 
        echo $row['ColumnTwo'];
        echo "</td><td>"; 
        echo $row['ColumnThree'];
        echo "</td></tr>"; 
    } 
    
    echo "</table>";
    ?>
    

    From: http://www.tizag.com/mysqlTutorial/mysqlselect.php

    2 – Data Storage

    Anything INSERT-ed into a database will remain* in the database until it is explicitly deleted.

    *with few exceptions – but you’ll learn about them a little later in your database journey 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.