@ob_start();
include 'include/connect.php';
include 'include/Form.php';
include '../admin/topmenu.php';
?>
print"
";
print"Add / Edit Question |
";
$rec_date=date("Y-m-d H:i:s");
if($_POST['submit']=='Add')
{
print $_POST['featured'];
$quest_id=generate_valid_id(get_next_id('quest_id'),5);
$insqry="insert into question (sub_id,quest_id,q_text,answer,featured,date_time) values('".$_POST['sub_id']."','".addslashes($quest_id)."','".addslashes($_POST['q_text'])."','".addslashes($_POST['answer'])."','".$_POST['featured']."','$rec_date')";
print $insqry;
//exit;
}
if($_POST['submit']=='Update')
{
$insqry="update question set sub_id='".addslashes($_POST['sub_id'])."',q_text='".addslashes($_POST['q_text'])."',answer='".addslashes($_POST['answer'])."',featured='".$_POST['featured']."' where quest_id='".$_POST['id']."'";
}
if($insqry!='')
{
$result=mysql_query($insqry) or die(mysql_error());
header('location:show_question.php');
}
$curform=new Html_form('Addedit_'.'question'.'.php','post','form1','','','chk_all','');
$curform->start();
if($_GET['id']!="")
{
$result=mysql_query("select * from question where quest_id='".$_GET['id']."'");
$row=mysql_fetch_object($result);
$curform->displayhidden("id",$_GET['id']);
}
$qry="SELECT * FROM subject ORDER BY sub_name";
$sub=get_list_data('subject','sub_id',array('sub_name'),'','SELECT * FROM subject ORDER BY sub_name');
$curform->displayselectrow('sub_id','Subject',$sub,$row->sub_id,'','','--SELECT--','','',1);
$curform->displaytextarearow('q_text','Question',$row->q_text,45,'','','1');
$curform->displaytextarearow('answer','Answer',$row->answer,45,'5','','1');
$curform->displayCheckboxRow('featured','Add to Featured FAQs?', 'Y','','');
if($_GET['id']=="")
{
$curform->displayhidden("submit","Add");
$curform->displaysubmitrow("submit1","Add");
}
else
{
$curform->displayhidden("submit","Update");
$curform->displaysubmitrow("submit1","Update");
}
$curform->end();
print"
";
?>