<html>
<body>
<center>
<div>
<form method="post" action="admission_list_fetch5.php">
Enter Cousre Code: <input name="course_code" placeholder="course code">
<input type="submit" name="submit" value="Submit">
</form>
PHP Разбивка с предложением WHERE
<div>
<table border="2" id="enquirytable" style= "border-collapse:collapse;"">
<thead>
<tr>
<th style="width:50;">SL No</th>
<th>Student ID</th>
<th>Enrol No</th>
<th>Name</th>
<th>Course</th>
<th>Semester</th>
</tr>
</thead>
<tbody>
<?php
//error_reporting(0);
$num_rec_per_page=10;
mysql_connect('localhost','root','');
mysql_select_db('nobledatabase');
if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * $num_rec_per_page;
$course_code=$_POST['course_code'];
$sql = "SELECT * FROM admission_list where course_code='$course_code' LIMIT $start_from, $num_rec_per_page";
$rs_result = mysql_query ($sql); //run the query
$i=1;
while($row = mysql_fetch_assoc($rs_result))
{
echo ("<tr><td style='text-align:center'>$i</td>".
"<td>{$row['student_id']}</td>".
"<td>{$row['enrol']}</td>".
"<td>{$row['name']}</td>".
"<td>{$row['course']}</td>".
"<td>{$row['sem_year']}</td></tr>\n");
$i++;
}
?>
</tbody>
</table>
<?php
$sql="SELECT * FROM admission_list where course_code='$course_code'";
$rs_result = mysql_query($sql); //run the query
$total_records = mysql_num_rows($rs_result); //count number of records
$total_pages = ceil($total_records/$num_rec_per_page);
?>
</div><!--enquirytable-->
<div class="enquirypages">
<br>
<?php
echo "<a href='admission_list_fetch5.php?page=1&course_code=$course_code'>".'<<'."</a> "; // Goto 1st page
for ($i=1; $i<=$total_pages; $i++) {
echo "<a href='admission_list_fetch5.php?page=".$i."&course_code=$course_code'> ".$i." ";
};
echo "<a href='admission_list_fetch5.php?page=$total_pages&course_code=$course_code'>".'>>'."</a> "; // Goto last page
?>
</div>
</div>
</center>
</body>
</html>
Даже если я передать параметры ко всем страницам, я получаю то же сообщение об ошибке:
Notice: Undefined index: course_code in C:\wamp\www\admission_list_fetch5.php on line 33
Скопируйте полное сообщение об ошибке на свой вопрос. –
Примечание: Неопределенный индекс: course_code в C: \ wamp \ www \ admission_list_fetch5.php в строке 33 –
Вы показываете код для admission_list_fetch5.php? это сообщение для себя? –