suppose the no_of_semester for the programe BCS are 8.
Now i have to put the no_of_semester value in a listbox but the no_of_semester will start from 1,2,3.....8, which will be defenetly done with the help of a loop.
I have the following logic applied but doesn't seems to work.
Code: Select all
<?php
include "connection.php";
$prog_name = $_POST['first'];
$sql = "SELECT programmes.no_of_semesters
FROM programmes
WHERE programmes.programe_name = '$prog_name' ";
$result = mysql_query($sql, $conn) or die (mysql_error());
while ($row = mysql_fetch_array($result)){
$sem = $row['no_of_semesters'];
}
$select = "<select id=\"semester\" name=\"semester\">
<option value=\"\">--Select--</option>";
for ($i=1;$i<=$sem;$i++)
{
$add .= "<option value='$sem[$i]'>$sem[$i]</option>";
echo "$add";
}
$select .="</select>";
echo "$select";
?>