plodos Posted May 22, 2008 Share Posted May 22, 2008 Dbase department CREATE TABLE department ( dept_id INT NOT NULL, dept_name TEXT, PRIMARY KEY (dept_id) ); combobox code <?php echo'<select name="department">'; $res=mysql_query("select * from department"); if(mysql_num_rows($res)==0) echo "there is no data in table.."; else for($i=1;$i<=mysql_num_rows($res);$i++) { $row=mysql_fetch_assoc($res); echo"<option>$row[dept_name]</option>"; } echo'</select>'; ?> it is listing the department names....but I need to take IDs... 1 PEDIATRICS 2 DIABETES 3 CARDIOLOGY How to use selectedIndex or how can I get the number of selected ındex Link to comment https://forums.phpfreaks.com/topic/106851-solved-php-combobox-problem-solved-thnx/ Share on other sites More sharing options...
jonsjava Posted May 22, 2008 Share Posted May 22, 2008 <?php echo'<select name="department">'; $res=mysql_query("select * from department"); if(mysql_num_rows($res)==0) echo "there is no data in table.."; else{ while ($row = mysql_fetch_assoc($res){ $id = $row['dept_id']; $name = $row['dept_name']; print "<option id='$id'>$name</option>\n"; } } echo'</select>'; ?> Link to comment https://forums.phpfreaks.com/topic/106851-solved-php-combobox-problem-solved-thnx/#findComment-547749 Share on other sites More sharing options...
plodos Posted May 23, 2008 Author Share Posted May 23, 2008 Dbase department CREATE TABLE department ( dept_id INT NOT NULL, dept_name TEXT, PRIMARY KEY (dept_id) ); combobox code <?php echo'<select name="department">'; $res=mysql_query("select * from department"); if(mysql_num_rows($res)==0) echo "there is no data in table.."; else for($i=1;$i<=mysql_num_rows($res);$i++) { $row=mysql_fetch_assoc($res); echo"<option>$row[dept_name]</option>"; } echo'</select>'; ?> it is listing the department names....but I need to take IDs... 1 PEDIATRICS 2 DIABETES 3 CARDIOLOGY How to use selectedIndex or how can I get the number of selected ındex Link to comment https://forums.phpfreaks.com/topic/106851-solved-php-combobox-problem-solved-thnx/#findComment-547774 Share on other sites More sharing options...
plodos Posted May 23, 2008 Author Share Posted May 23, 2008 <?php <form action="_update.php" method="post" id="_editform" > echo'<select name="proficiency">'; $res=mysql_query("select * from proficiency"); if(mysql_num_rows($res)==0) { echo "there is no data in table.."; } else { while ($row = mysql_fetch_assoc($res) ) { $id = $row['p_id']; $name = $row['p_name']; print "<option id='$id'>$name</option>\n"; } } echo'</select>'; <input type="submit" name="Submit" value="SAVE "> </form> ?> _update.php $_p_id = $_POST['proficiency']; // it show the selected name How can I take the OPTON ID $_p_id = $_POST['id']; //it is not working Link to comment https://forums.phpfreaks.com/topic/106851-solved-php-combobox-problem-solved-thnx/#findComment-547791 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.