Forum Moderators: open
Here is the basic gist of what I am trying to produce. I have a site which contains 10 news articles listed in 'most recent first' format. The site will be consistently updated by another who is submitting articles 2-3 a day. Here's where my questions begin.
One, I understand that he can fill in a form and that assigned value can be transferred eventually to the database.
Okay, since part of the submission process redirects you to another page, i.e form action="newpage.php" method="post" what exactly needs to be on the page with the textbox? Does it need to connect to the mySQL server there?
Also, for the next page, the one it goes to. Right now, I am just trying to assign the value of the form submission to fit in the 12th spot of my table(named articles), named 'newa' . I thought I had the basic idea, but on a query of the article gave me a syntax error of 1064.
Here is my basic coding I have implemented so far. Table is called articles
<?php
$hostname="server";
$username="username";
$password="pw";
$dbname="database";
$connectID=mysql_connect($hostname,$username, $password)
or die("Cannot Connect to Server");
mysql_select_db($dbname);
$newpost=$_POST['newsa'];
$query = "INSERT INTO articles(newa) VALUES ('$newpost')";
mysql_query($query);
mysql_close($connectID);
?>
While I'm here, let me check on this also. My Table looks like this
id
a1
a2
a3
a4
a5
a6
a7
a8
a9
a10
newa
Whenever the text box is filled in and submitted. I want the value of the box to assign to newa. Then I went a10 to take on the value of a9, a9 to take on the value of a8, etc... with a1 taking on newa. Would this be the best way to do that? Or at least...work?
mysql_query('INSERT into articles(a10, a9, a8, a7, a6, a5, a4, a3, a2, a1) VALUES (a9, a8, a7, a6, a5, a4, a3, a2, a1, newa);
Let me know if I'm even in the ball park. Lots of stuff here, again I'm very grateful.
SELECT ArticleTitle, ArticleBody
FROM tblArticle
WHERE ArticleID=1; Or for selecting all fields from the ten most recent records:
SELECT *
FROM tblArticle
ORDER BY ArticleDate DESC
LIMIT 10; Assuming field names and table name as above, and you're using MySql. HTH