Hello :)

I have a quick question with a script I'm making;
It's a php script used to add data to pages (there are 5 in total and an index page), and I just restructured the database for more efficiency :o . It used to look like this:

+-------+--------+--------+-------+--------+--------+
| Page1 | Page2 | Page3 | Page4 | Page5 | Index |
+-------+--------+--------+-------+--------+--------+
| Text | Text | Text | Text | Text | Text |
+-------+--------+--------+-------+--------+--------+

Now it looks like this:

+-----+-------------+
| ID | Page Text |
+-----+-------------+
| 1 | Text |
+-----+-------------+
| 2 | Text |
+-----+-------------+
| 3 | Text |
+-----+-------------+
| 4 | Text |
+-----+-------------+
| 5 | Text |
+-----+-------------+
| 6 | Text | (index page)
+-----+-------------+

Now, the old code for adding text was:

$pagenumber = $_POST['pagenumber'];
$sql = mysql_query("INSERT INTO pages (`pagenumber`) values ('$pagenumber')");

(pagenumber substituted from real database names for showing general usage :p)

And that worked fine; but now I'm not sure how to set it up :( .

Any help would be appreciated :)

EDIT:
My boxes fail with vBulletin >8(

Recommended Answers

All 2 Replies

I am not exactly sure what you are wanting but I would use this code to insert text into the database

<?php

if (isset($_POST['submit'])) {
  $page = $_POST['page']; //ID OF PAGE
  $text = $_POST['text']; //TEXT FOR THAT PAGE
  $sql   = "UPDATE `pages` SET `page_text` = '" . $text . "' WHERE `ID` = " . $id;
  $query = mysql_query($sql) or die('Error: ' . mysql_error());
}

?>

Thank you :)

The id isn't able to be changed, but I was confused with the code for updating the database :o .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.