I do have parts of the project working; however, I'm stumped again.
Here's the issue::
I am making a page (for editing and adding) that is merely links to the pages that will actually do the modification and/or addition that I need.
Here's what I need to do:
The article-edit page that I have so far is this...
<?
$number = $_GET['number'];
include 'settings.php'; // Include the settings file!
$connection = mysql_connect($mysql_host, $mysql_user, $mysql_password); // Connect to the MySQL server!
mysql_select_db($mysql_db, $connection) or trigger_error('Can NOT select '. $mysql_db . ' database because ' . mysql_error(), E_USER_ERROR); // Select the db!
$query = "SELECT s.section_id, s.section_title, a.article_id, a.article_title, a.article_text";
$query .= " FROM articles As a LEFT JOIN sections As s";
$query .= " ON a.section_id = s.section_id";
$query .= " WHERE a.article_id = $number";
$query .= " ORDER BY s.section_id, a.article_title, a.article_text";
$result = mysql_query($query, $connection) or trigger_error(mysql_error(), E_USER_ERROR);
while($array = mysql_fetch_array($result))
{
$section_id = str_replace(' ',' ',$array['section_id']);
$section_title = str_replace(' ',' ',$array['section_title']);
$article_id = str_replace(' ',' ',$array['article_id']);
$article_title = str_replace(' ',' ',$array['article_title']);
$article_text = str_replace(' ',' ',$array['article_text']);
?>
<form method=post action=article-db-edit.php>
<input type=hidden name=new_article_id value=<? echo $article_id; ?>>
<table>
<tr>
<td align=right>Section Title: </td>
<td>
<input name=new_section_title type=text size=100 tabindex=1 value=<? echo $section_title; ?>>
</td>
</tr>
<tr>
<td align=right>Article Title: </td>
<td><input name=new_article_title type=text size=100 tabindex=2 value=<? echo $article_title; ?>></td>
</tr>
<tr>
<td align=right>Article Text: </td>
<td><textarea name=new_article_text cols=85 rows=5 tabindex=2><? echo $article_text; ?></textarea></td>
</tr>
<tr>
<td colspan=2 align=center><input name=Submit type=submit value=submit><input name=Reset1 type=reset value=reset></td>
</tr>
</table>
</form>
<?
}
?>
When you pass $number (the article_id number in the articles table,) it displays the proper values that are associated to both tables.
Now, what I need to do is to modify that so that the section_id is connected with the appropriate section_title so that if the section itself is modified via this form, the appropriate section_id AND section_title are modified. So far, I've been unsuccessful.
Something that at least functions similarly to what I'd need would be to have one dropdown (section_title) that would modify a second dropdown (section_id) within this form.
Here's a javascript/html example that would do the modifying the actual dropdown menus; however, how to I integrate it into my script to do what I need?
<html>
<head>
<link rel=stylesheet href="1dynamicMenu.css" type="text/css">
<script language="JAVASCRIPT" src="1js.js">
<!--//
//--></script>
<script language="javascript"
src="BackForwardNew.js">
<!--//
//--></script>
<meta name="description" content="Using a select to write a select (Double menus)">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage 12.0">
<style type="html/txt">
<!--h2 { color: rgb(128,0,0) }
h1 { text-align: center; color: rgb(103,104,74) }
-->
</style>
<!--start of function-->
<script language="javascript">
<!--//
function ldMenu(mySubject) {
var Indx=mySubject;
with (document.form2.select2)
{
document.form2.select2.options.length=0;
if (Indx==0)
{
options[0]=new Option("Pages appear here","");
}
if (Indx==1)
{
options[0]=new Option("Choose a JavaScript Page","");
options[1]=new Option("Alerts","alerts.htm");
options[2]=new Option("Back and Forward Buttons","BackForward.htm");
options[3]=new Option("Contents","index.html");
}
if (Indx==2)
{
options[0]=new Option("Choose an HTML Page","");
options[1]=new Option("HTML Contents","../HTMLGuide/index.html");
options[2]=new Option("Meta Tags","../HTMLGuide/metaTags.htm");
options[3]=new Option("Hyperlinks","../HTMLGuide/ImageHyperlink.htm");
options[4]=new Option("iframes","../HTMLGuide/iframes3.htm");
}
if (Indx==3)
{
options[0]=new Option("Choose a Style Sheets Page","");
options[1]=new Option("Style Sheets Contents","../StyleSheets/index.html");
options[2]=new Option("Fonts","../StyleSheets/fonts.htm");
}
form2.select2.options[0].selected=true;
}
}
//-->
</script>
<!--end of function-->
<script language="JavaScript">
<!-- Hide from old browsers
//Hide from Java Script
function goToPage()
{
PageIndex2=document.form2.select2.selectedIndex
if (document.form2.select2.options[PageIndex2].value != "")
{
location.href = document.form2.select2.options[PageIndex2].value;
}
}
//-->
</script>
<meta name="KEYWORDS"
content="javascript,menus,form,select,onChange,onChange,new Option,options,location.href,HTML,navigator.appName ,history.go(0),">
<link rel="stylesheet" href="javascript.css" type="text/css">
<title>Using a menu to write a menu</title>
</head>
<body vlink="green" alink="blue" link="red" background="backg2.gif">
<form name="form1">
<p><select name="select1" onChange="ldMenu(this.selectedIndex);" size="1">
<option value selected>Select a subject </option>
<option value>JavaScript </option>
<option value>HTML </option>
<option value>Style Sheets </option>
</select> </p>
</form>
<form name="form2" method="post" action enctype="text/plain">
<p><select name="select2" onChange="goToPage()" size="1">
<option selected value="Select a page after selecting a subject">Select a page
after selecting a subject</option>
</select> </p>
</form>
</body>
</html>
Any ideas on how to do this?
Thanks for all the help thus far!
wrstrong