Hello everybody,
Breifly, I've 3 list boxes.Select a record from the first one, click a buttoon, the second list box is filled and select a record now and then click a button, the third list box is filled.Now, select the record, the selected record has to be shown in the text box.But, I also want to show one more field related to this one in another text box.How can i do??
well, the first list box shows the topic names, 2nd one the sub-topic names and the third one the article names.
Now when i select the article name, the article name and the article content has to be shown in the text boxes.
It its just article name, i know how to do it by java-script but i also need article content to be shown.
Could somebody please help me how should i modify my code and where should i insert the text boxes??
Also, one more question, If i make any changes to the data in the text boxes, i would like to update.How can i do that??
Many thanks.
Here is my code:
<?php
//DB connection details
?>
<html>
<head>
<title>Update the article information</title>
</head>
<body>
<?
if (isset($HTTP_POST_VARS ["TOPIC_ID"])) {
$TOPIC_ID=(int)$HTTP_POST_VARS ["TOPIC_ID"];
$q=mysql_query("select * from topic where TOPIC_ID=$TOPIC_ID");
if (!mysql_num_rows($q))
$TOPIC_ID=0;
} else {
$TOPIC_ID=0;
}
if ($TOPIC_ID && isset($HTTP_POST_VARS ["SUBTOPIC_ID"]) && $HTTP_POST_VARS ["submitname"]!="Change") {
$SUBTOPIC_ID=(int)$HTTP_POST_VARS ["SUBTOPIC_ID"];
$q=mysql_query("select * from subtopic where TOPIC_ID=$TOPIC_ID and SUBTOPIC_ID=$SUBTOPIC_ID");
if (!mysql_num_rows($q))
$SUBTOPIC_ID=0;
} else {
$SUBTOPIC_ID=0;
}
if ($SUBTOPIC_ID && isset($HTTP_POST_VARS ["ARTICLE_ID"]) && $HTTP_POST_VARS ["submit"]!="Change") {
$ARTICLE_ID=(int)$HTTP_POST_VARS ["ARTICLE_ID"];
$q=mysql_query("select * from articles where ARTICLE_ID=$ARTICLE_ID and SUBTOPIC_ID=$SUBTOPIC_ID");
if (!mysql_num_rows($q))
$ARTICLE_ID=0;
} else {
$ARTICLE_ID=0;
}
// If we got here, we need to display the form...
echo "<html><form method=post action=\"$PHP_SELF\">";
echo "<select name=TOPIC_ID>";
$q=mysql_query("SELECT * FROM topic ORDER BY TOPIC_NAME");
while ($l=mysql_fetch_array($q)) {
$selected="";
if ($l["TOPIC_ID"]==$TOPIC_ID)
$selected="selected=1";
echo "<option value=\"".$l["TOPIC_ID"]."\" $selected>".$l["TOPIC_NAME"];
}
echo "</select>";
echo " <input type=submit name=submitname value=\"Change\"> ";
echo "<br><br>";
echo "<select name=SUBTOPIC_ID>";
if ($TOPIC_ID) {
$q=mysql_query("SELECT * FROM subtopic WHERE TOPIC_ID=$TOPIC_ID");
while ($l=mysql_fetch_array($q)) {
$selected="";
if ($l["SUBTOPIC_ID"]==$SUBTOPIC_ID)
$selected="selected=1";
echo "<option value=\"".$l["SUBTOPIC_ID"]."\" $selected>".$l["SUBTOPIC_NAME"];
}
} else {
echo "<option value=0>Please select topic first";
}
echo "</select>";
echo " <input type=submit name=submit value=\"Change\"> ";
echo "<br><br>";
echo "<select name=ARTICLE_ID>";
if ($SUBTOPIC_ID) {
$q=mysql_query("SELECT * FROM articles WHERE SUBTOPIC_ID=$SUBTOPIC_ID");
while ($l=mysql_fetch_array($q)) {
$selected="";
if ($l["SUBTOPIC_ID"]==$SUBTOPIC_ID)
$selected="selected=1";
echo "<option value=\"".$l["ARTICLE_ID"]."\" $selected>".$l["ARTICLE_NAME"];
}
} else {
echo "<option value=0>Please select subtopic first";
}
echo "</select>";
echo "<br><br>";
// To get the article name and the article content
//I guess i need to inser the code here which shows me the textboxes and transfer the article name and article content, am mi right?
echo "</form>";
</body>
</html>