Page 1 of 1

Unable to show anything in the Dropdown

Posted: Sat Sep 20, 2014 12:37 pm
by Imran101
I am in dire need of someone's help with this. After I make changes to the code, everything after city disappears and I still get nothing in the drop-down to pick a city from.

Before the change:

Code: Select all

<?php include_once("includes/header.php");?>
<form name="student_frm" action="">
<table width="90%" border="2" align="center">
<tr>
	<th colspan="4" scope="col">Student Registration Form</th>
</tr>
<tr>
	<th>First Name</th>
		<td><input name="st_frtname" type="text" id="st_frtname"></td>
	<th>Last Name</th>
		<td><input name="st_ltname" type="text" id="st_ltname"></td>
</tr>
<tr>
	<th>Address Line 1</th>
		<td><textarea name="st_address1" id="st_address1"></textarea></td>
	<th>Address Line 2</th>
		<td><textarea name="st_address2" id="st_address2"></textarea></td>
</tr>
<tr>
	<th>City</th>
		<td>
			<select name="st_city" id="st_city">
			<?php ###echo get_option_list("city","city_id","city_name"); ?>
			</select>
		</td>		
	<th>State</th>
		<td><select name="st_state" id="st_state">
			<?php ###echo get_option_list("state","state_id","state_name"); ?>
			</select>
		</td>
</tr>
<tr>
	<th>Country</th>
		<td><select name="st_country" id="st_country">
			<?php ###echo get_option_list("country","country_id","country_name"); ?>
		</select>
		</td>
	<th>Citizenship</th>
		<td><input name="st_citizen" type="text" id="st_citizen"></td>
</tr>
<tr>
	<th>Gender</th>
		<td>
			<input name="st_gender" type="radio" value="radiobutton">Male
			<input name="st_gender" type="radio" value="radiobutton">Female
		</td>
	<th>Qualification</th>
		<td>
			<div style="height:100; overflow:scroll">
				<?php ###echo get_check_list("course","course_id","course_name","st_qualify"); ?>
			</div>
		</td>
</tr>
<tr>
	<th>Course</th>
		<td><select name="st_course" id="st_course"></select></td>
	<th>picture</th>
		<td><input name="st_picture" type="file" id="st_picture"></td>
</tr>
<tr>
	<th>Hobbies</th>
		<td><textarea name="st_hobbies" id="st_hobbies"></textarea></td>
	<th>Mobile</th>
		<td><input name="st_mobile" type="text" id="st_mobile"></td>
</tr>
<tr>
	<th colspan="4">
		<input type="submit" name="submit" value="Submit">
		<input type="reset" name="submit2" value="Reset">
	</th>
</tr>
</table>
</form>
<?php include_once("includes/footer.php");?>


After the change:

Code: Select all

<?php include_once("includes/header.php");?>
<form name="student_frm" action="">
<table width="90%" border="2" align="center">
<tr>
	<th colspan="4" scope="col">Student Registration Form</th>
</tr>
<tr>
	<th>First Name</th>
		<td><input name="st_frtname" type="text" id="st_frtname"></td>
	<th>Last Name</th>
		<td><input name="st_ltname" type="text" id="st_ltname"></td>
</tr>
<tr>
	<th>Address Line 1</th>
		<td><textarea name="st_address1" id="st_address1"></textarea></td>
	<th>Address Line 2</th>
		<td><textarea name="st_address2" id="st_address2"></textarea></td>
</tr>
<tr>
	<th>City</th>
		<td>
			<select name="st_city" id="st_city">
			<?php echo get_option_list("city","city_id","city_name"); ?>
			</select>
		</td>		
	<th>State</th>
		<td><select name="st_state" id="st_state">
			<?php ###echo get_option_list("state","state_id","state_name"); ?>
			</select>
		</td>
</tr>
<tr>
	<th>Country</th>
		<td><select name="st_country" id="st_country">
			<?php ###echo get_option_list("country","country_id","country_name"); ?>
		</select>
		</td>
	<th>Citizenship</th>
		<td><input name="st_citizen" type="text" id="st_citizen"></td>
</tr>
<tr>
	<th>Gender</th>
		<td>
			<input name="st_gender" type="radio" value="radiobutton">Male
			<input name="st_gender" type="radio" value="radiobutton">Female
		</td>
	<th>Qualification</th>
		<td>
			<div style="height:100; overflow:scroll">
				<?php ###echo get_check_list("course","course_id","course_name","st_qualify"); ?>
			</div>
		</td>
</tr>
<tr>
	<th>Course</th>
		<td><select name="st_course" id="st_course"></select></td>
	<th>picture</th>
		<td><input name="st_picture" type="file" id="st_picture"></td>
</tr>
<tr>
	<th>Hobbies</th>
		<td><textarea name="st_hobbies" id="st_hobbies"></textarea></td>
	<th>Mobile</th>
		<td><input name="st_mobile" type="text" id="st_mobile"></td>
</tr>
<tr>
	<th colspan="4">
		<input type="submit" name="submit" value="Submit">
		<input type="reset" name="submit2" value="Reset">
	</th>
</tr>
</table>
</form>
<?php include_once("includes/footer.php");?>


Here is the function.php file

Code: Select all

<?php
###Function to generate dynamic option list###
function get_option_list($table,$col_id,$col_value,$sel=0)
{
	$SQL="SELECT * FROM $table ORDER BY $col_value";
	$rs=mysql_query($SQL) or die(mysql_error());
	$option_list="<option value=0>Please Select</option>";
	while($data=myssql_fetch_assoc($rs))
	{
		$option_list.="<option value='$data[$col_id]'>
$data[$col_value]</option>";
	}
	return $option_list;
}
###Function to generate dynamic checkbox###
function get_check_list($table,$col_id,$col_value,$name,$sel=0)
{
	$SQL="SELECT * FROM $table ORDER BY $col_value";
	$rs=mysql_query($SQL) or die(mysql_error());
	$option_list="";
	while($data=myssql_fetch_assoc($rs))
	{
		$option_list.="<input type='checkbox' name='$name' value='$data[$col_id]'>$data[$col_value]<br>";
	}
	return $option_list;
}
?>

Re: Unable to show anything in the Dropdown

Posted: Sat Sep 20, 2014 6:29 pm
by Celauran
Are you seeing any errors? Is error reporting turned on? Is that function file being included?

Re: Unable to show anything in the Dropdown

Posted: Sat Sep 20, 2014 6:30 pm
by Celauran

Code: Select all

 myssql_fetch_assoc
That's not going to work.

Re: Unable to show anything in the Dropdown

Posted: Sat Sep 20, 2014 7:39 pm
by Imran101
The function.php is part of the header.php file. I am really new to PHP. I tried using mysql_fetch_array but I got the same result.

Re: Unable to show anything in the Dropdown

Posted: Sat Sep 20, 2014 7:42 pm
by Imran101
How do I turn on error reporting? I am using XAMPP on my local machine.

Re: Unable to show anything in the Dropdown

Posted: Sat Sep 20, 2014 9:46 pm
by Celauran
http://php.net/manual/en/function.error-reporting.php
http://php.net/manual/en/errorfunc.conf ... lay-errors
Imran101 wrote:I tried using mysql_fetch_array but I got the same result.
I was pointing out the extra s in myssql. You really shouldn't be using mysql_ anything, though. That has been deprecated since forever.