GETメソッドを持つ2つのフォームがあります。最初のフォームを送信すると、このURLが表示されます
http://127.0.0.1/astronomy/student_enrollment.php?class_name_data=1&classNameGetDetails=
GETメソッドもある2番目のフォームを送信すると。私のURLはこれに変更されました
http://127.0.0.1/astronomy/student_enrollment.php?class_name_for_enrollment=Planet&sy_for_enrollment=2012-2013&sy_for_enrollment=45&number_of_student_enrolled=&time_schedule_student=Monday+to+Friday+8%3A00-9%3A00&generateFields=Generate
最初のクエリ文字列が削除され、2番目のクエリ文字列に置き換えられました
URLを次のようにします
http://127.0.0.1/astronomy/student_enrollment.php?class_name_data=1&classNameGetDetails=&class_name_for_enrollment=Planet&sy_for_enrollment=2012-2013&sy_for_enrollment=45&number_of_student_enrolled=&time_schedule_student=Monday+to+Friday+8%3A00-9%3A00&generateFields=Generate
&
2つのクエリ文字列は、ではなくの区切り文字と結合されます?
。どうすればいいですか?
これは私のコードです
<div class="enrollmentContent">
<div class="classNameChoices">
<label>Choose Class Name</label>
<form action="" method="get">
<select name="class_name_data">
<?php
$table = "classes";
$data = array(
'teacher_id' => $session_id
);
$class_name_query = show_filtered_rows($table, $data);
while($rows = mysql_fetch_array($class_name_query)){
$id = $rows['id'];
$class_name = $rows['class_name'];
?>
<option value="<?php echo $id; ?>"><?php echo $class_name; ?></option>
<?php
}
?>
</select>
<input type="submit" name="classNameGetDetails" value="" />
</form>
</div>
<?php
if(isset($_GET['classNameGetDetails'])){
$data2 = array(
'id' => $_GET['class_name_data'],
'teacher_id' => $session_id
);
$class_name_data_query = show_filtered_rows($table, $data2);
$rows_class = mysql_fetch_array($class_name_data_query);
?>
<div class="classDetailsByClassName">
<form action="" method="get">
<input type="hidden" value="<?php echo $rows_class['class_name']; ?>" name="class_name_for_enrollment" />
<input type="hidden" value="<?php echo $rows_class['school_year_from']."-".$rows_class['school_year_to']; ?>" name="sy_for_enrollment" />
<input type="hidden" value="<?php echo $rows_class['enrollees']; ?>" name="sy_for_enrollment" />
<label>Class Name <span><?php echo $rows_class['class_name']; ?></span></label>
<label>SY <span><?php echo $rows_class['school_year_from']."-".$rows_class['school_year_to']; ?></span></label>
<label>Maximum No. of Enrollees <span><?php echo $rows_class['enrollees']; ?></span></label>
<div class="registerDetails">
<div>
<label>Number of students to enroll</label>
<div><input type="number" name="number_of_student_enrolled" value=""/></div>
</div>
<div>
<label>Schedule</label>
<div>
<select name='time_schedule_student'>
<option value="Monday to Friday 8:00-9:00">Monday to Friday 8:00-9:00</option>
<option value="Monday to Friday 10:00-11:00">Monday to Friday 10:00-11:00</option>
<option value="Monday to Friday 1:00-2:00">Monday to Friday 1:00-2:00</option>
<option value="Monday to Friday 2:00-3:00">Monday to Friday 2:00-3:00</option>
<option value="Monday to Friday 9:00-10:00">Monday to Friday 9:00-10:00</option>
<option value="Monday to Friday 3:00-4:00">Monday to Friday 3:00-4:00</option>
</select>
</div>
</div>
<div><input type="submit" name="generateFields" value="Generate" /></div>
</div>
</form>
</div>
<div class="enrollmentFields">
<?php
if(isset($_GET['generateFields'])){
echo $_GET['class_name_for_enrollment'];
}
?>
</div>
<?php
}
?>
</div>
と私の機能
function show_filtered_rows($table, $data){
foreach($data as $fields=>$field_data){
$show_data[] = "`".$fields."` = '".$field_data."'";
}
return mysql_query("SELECT * FROM `$table` WHERE ".implode(" AND ",$show_data));
}