balkan7 Posted February 14, 2007 Share Posted February 14, 2007 where i wrong whit get command in select option ? subcategory.php <?php require_once("../conn.php"); require_once("../functions.php"); require_once("access.php"); require_once("header.php"); if (isset($_POST['s2'])) { $tName = trim($_POST['newname']); if (!empty($tName)) { $q1 = "insert into sub_category set cat_id = '$_GET[iD]', newname = '$tName' "; $r1 = mysql_query($q1) or die(mysql_error()); } else { $error = "<span class=RedLink>Enter the New Subcategory name, please!</span>"; } if(!mysql_error() && empty($error)) { header("location:subcategory.php"); exit(); } } $q1 = "select * from category where kat_id = '$_GET[iD]'"; $r1 = mysql_query($q1) or die(mysql_error()); $a1 = mysql_fetch_array($r1); ?> <br> <table align=center> <caption align=center class=Nav>Add new SubCategory</caption> <tr> <td>Choice Category:</td> <td> <form method=get action="subcategory.php"> <select name=ID> <?php $q1 = "select * from category order by cat_name"; $r1 = mysql_query($q1) or die(mysql_error()); while($a1 = mysql_fetch_array($r1)) { echo "<option value=$a1[cat_id]>$a1[cat_name]\n"; } ?> </select></td> <table align=center> <tr> <td>Subcategory Name:</td> <td><input type=text name=newname></td> <input type=hidden name=ID value="<?=$_GET[iD]?>"> </tr> </table> <table align=right> <tr> <td style="width: 234px"><input type=submit name=s2 value=Submit></td> </tr> </form> </table> <br><br> <?php $q1 = "select * from kategorija order by cat_name"; $r1 = mysql_query($q1) or die(mysql_error()); if(mysql_num_rows($r1) > '0') { echo "<table align=center width=400 cellspacing=0>\n<caption align=center class=Nav>Categoryes and SubCategoryes</caption>\n\n"; $col = "white"; while($a1 = mysql_fetch_array($r1)) { if($col == "white") { $col = "dddddd"; } else { $col = "white"; } echo "<tr bgcolor=$col>\n\t<td class=Nav>$a1[cat_name]</td>\n\t<td>\n</td></tr>\n\n"; //get the subcategories $q3 = "select * from sub_category where cat_id = '$a1[cat_id]' "; $r3 = mysql_query($q3) or die(mysql_error()); if(mysql_num_rows($r3) > '0') { while($a3 = mysql_fetch_array($r3)) { echo "<tr bgcolor=$col>\n\t<td style=\"padding-left:10\">$a3[sub_name]</td>\n\t<td align=center width=100><a class=GreenLink href=\"edit_subcat.php?cat_id=$a1[cat_id]&pod_id=$a3[pod_id]\">edit</a> | <a class=RedLink href=\"delete.php?sub=del&cat_id=$a1[cat_id]&sub_id=$a3[sub_id]\" onclick=\"return cdel('');\">delete</a></td>\n</tr>\n\n"; } } } echo "</table>\n\n<br><br>"; } ?> Link to comment https://forums.phpfreaks.com/topic/38431-_get-i-select-option/ Share on other sites More sharing options...
Psycho Posted February 14, 2007 Share Posted February 14, 2007 Assuming you are properly passing a variable on the query string, the problem is that you are trying to include the variable within single quotes. If you want variables to be interpreted within a string, they need to be in double quotes. $foo = "bar"; $test1 = "The value is: $foo"; $test2 = 'The value is: $foo'; echo $test1; // output: "The value is: bar" echo $test2; // output: "The value is: $foo" Link to comment https://forums.phpfreaks.com/topic/38431-_get-i-select-option/#findComment-184361 Share on other sites More sharing options...
redarrow Posted February 14, 2007 Share Posted February 14, 2007 save this as testing.php and see why. this get the info from a link try it. <?php echo"<a href='testing.php?example=abc'>link</a>"; ?> <select> <?php $e=$_GET['example']; echo "<option name='example' value='$e'>$e</option>"; ?> </select> this get the info from the page varables <select> <?php $x=array("a","b","c"); foreach ( $x as $e){ echo "<option name='example' value='$e'>$e</option>"; } ?> </select> Link to comment https://forums.phpfreaks.com/topic/38431-_get-i-select-option/#findComment-184364 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.