This is my first shot at creating an original script - all bymyself to let a user update a mysql field. This is what it does:
- You select the date of the article
- You select the title
If you did that, you get a congrats message (I will finish after I get this bug fixed - the bug is why I am posting this). Note you can only do each step at a time, meaning that's all the page displays.
Here is the code:
//Required Variables
$author = "Sharif Tanvir Karim";
//Begin Script
if (!isset($_POST['article_date']))
{
echo ("<center>Please select the date of the article you want to edit by selecting a date from the drop down menu below");
echo ("<form name=\"select_article_date\" action=\"updater.php\" method=\"post\">");
echo ("<select name=\"article_date\" onChange=\"document.select_article_date.submit();\">");
//Start SQL Query To Pull Data
$query = mysql_query ("SELECT date FROM news WHERE author='$author' ORDER BY date DESC");
while ($row = mysql_fetch_array($query))
{
$date = $row["date"];
//List the options for the list field
echo "<option>";
echo $date;
echo "</option>";
}
//Close HTML
echo ("</select>");
echo ("</form>");
echo ("</center>");
}
elseif (!isset($_POST['article']))
{
echo ("<center>Please select an article to edit by selecting an article from the drop down menu below");
echo ("<form name=\"select_article\" action=\"updater.php\" method=\"post\">");
echo ("<select name=\"article\" onChange=\"document.select_article.submit();\">");
//Start SQL Query To Pull Data
$query = mysql_query ("SELECT title FROM news WHERE author = '$author' AND date = '$article_date' ORDER BY title ASC");
while ($row = mysql_fetch_array($query))
{
$title = $row["title"];
//List the options for the list field
echo "<option>";
echo $title;
echo "</option>";
}
//Close HTML
echo ("</select>");
echo ("</form>");
echo ("</center>");
}
//if all succedds
elseif (isset($_POST['article']) && isset($_POST['article_date']))
{
echo ' you did it ';
}
The problem is, after you pick the date and the page refreshes to pick the article, and you pick the article, you end up having to pick the date again. Why? Please do not worry about ALL of the sql queries, I purposely put SOME screwy stuff because I am not done with all the sql stuff. But for now, please help me out.