0

I am using the code below:

  <form>
<textarea cols="50" rows="4" name="link"></textarea>
<textarea cols="50" rows="4" name="notes"></textarea>
<input type="submit" value="Submit">
</form>

I need code to insert it into a MySQL database and then code to display the contents of that MySQL database in a long list of link and notes going like:

link

note

2link

2note

but without the number 2 and in either a PHP or HTML file or both.

How would I accomplish this?

Regards!

1 Answer 1

1

Inserting:

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

Selecting:

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

To get the value, you first have to add two more parameters to your form tag:

method, which is how the values will be passed (google post/get)

and action, which is the page where the form will be submitted to, and processed

Like this:

<form method="post" action="path/another_page.php">

The, in another_page.php, you can use PHP's $_POST variable to retrieve the values:

$sql = "INSERT INTO table_name (link, notes) VALUES ( {$_POST['link']} , {$_POST['notes']} )";

If you want to add the numbers, you can both use an sequential id, or add them programatically, like this:

$i = 0;
while($row = mysql_fetch_array($result))
  {
  ++$i;
  echo $i .") " . $row['FirstName'] . " " . $row['LastName'];
  echo "<br />";
  }
Sign up to request clarification or add additional context in comments.

1 Comment

Ok, I edited my answer, see if it's more specific with your question now

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.