ferlicia Posted July 22, 2011 Share Posted July 22, 2011 this is the form for my assignment Criteria: <form method="post" action="doSelectCriteria.php"> <select name="criteria"> <option value="selectCriteria">Select Criteria</option> <option value="GPA">GPA</option> <option value="Diploma">Diploma</option> <option value="Gender">Gender</option> <option value="LearningAttitudes">Learning Attitudes</option> </select> </form><br><br> Additional Criteria: <form method="post" action="doSelectCriteria.php"> <p><label for="criteria">Criteria Name: </label> <input name="criteria" type="text"></p> <p><input name="btnsubmit" value="Submit" type="submit"></p> </form> <br> next page (to carry out the selection ) $criteria = $_POST['criteria']; but when i echo to see the $criteria that i have selected, it is not shown why? is there any error? Quote Link to comment https://forums.phpfreaks.com/topic/242607-i-am-not-able-to-post-why/ Share on other sites More sharing options...
QuickOldCar Posted July 22, 2011 Share Posted July 22, 2011 <form method="post" action=""> <select name="criteria"> <option value="selectCriteria">Select Criteria</option> <option value="GPA">GPA</option> <option value="Diploma">Diploma</option> <option value="Gender">Gender</option> <option value="LearningAttitudes">Learning Attitudes</option> </select> <input type="submit" /> </form><br><br> <?php $criteria = $_POST['criteria']; echo $criteria; ?> Quote Link to comment https://forums.phpfreaks.com/topic/242607-i-am-not-able-to-post-why/#findComment-1246037 Share on other sites More sharing options...
darkfreaks Posted July 22, 2011 Share Posted July 22, 2011 you need to put a hidden field inside your form <form method="post" action="doSelectCriteria.php"> <input type="hidden" name="criteria" value="<?=$_POST['criteria'];?>" /> <select name="criteria"> <option value="selectCriteria">Select Criteria</option> <option value="GPA">GPA</option> <option value="Diploma">Diploma</option> <option value="Gender">Gender</option> <option value="LearningAttitudes">Learning Attitudes</option> </select> <input type="submit" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/242607-i-am-not-able-to-post-why/#findComment-1246061 Share on other sites More sharing options...
darkfreaks Posted July 23, 2011 Share Posted July 23, 2011 you could also use sessions if preferred over hidden fields. $options=array(); $options['SelectCriteria']; $options['GPA']; $options['Diploma']; $options['Gender']; $options['LearningAttitdes']; $_SESSION['criteria'] = (isset($_POST['critieria']) ? !empty($_POST['criteria') : $_SESSION['criteria']); echo"<select name="criteria">"; foreach($option as $key => $val) { echo "<option" . ($val == $_SESSION['criteria'] ? " selected" : "") . ">$val</option>"; } echo "</select>"; Quote Link to comment https://forums.phpfreaks.com/topic/242607-i-am-not-able-to-post-why/#findComment-1246425 Share on other sites More sharing options...
ferlicia Posted July 25, 2011 Author Share Posted July 25, 2011 the criteria are still not posted.. this was my whole form <form method="post" action="doSelectCriteria.php"> <input type="hidden" name="criteria" value="<?=$_POST['criteria'];?>" /> <select name="criteria"><option value="selectCriteria">Select Criteria</option> <option value="GPA">GPA</option><option value="Diploma">Diploma</option> <option value="Gender">Gender</option> <option value="LearningAttitudes">Learning Attitudes</option> </select> </form> Additional Criteria: <form method="post" action="doSelectCriteria.php"> <p><label for="criteria">Criteria Name: </label> <input name="criteria" type="text"></p> <p><input name="btnsubmit" value="Submit" type="submit"></p> </form> <br> then for the next page $criteria = $_POST['criteria']; $result_1= mysqli_query($link, "SELECT * FROM studentdetails, criteria WHERE studentdetails.StudentID = criteria.StudentID ORDER BY gpa ASC"); i am not able to post the result that have been choosen and for the query, i wanted to order by the the criteria that i have choosen instead of gpa, but there will be error please help Quote Link to comment https://forums.phpfreaks.com/topic/242607-i-am-not-able-to-post-why/#findComment-1246518 Share on other sites More sharing options...
QuickOldCar Posted July 25, 2011 Share Posted July 25, 2011 change this: <input type="hidden" name="criteria" value="<?=$_POST['criteria'];?>" /> to this: <input type="hidden" name="criteria" value="<?php echo $_POST['criteria'];?>" /> also try to echo criteria and see if gets a value $criteria = $_POST['criteria']; echo $criteria;//test echo criteria $result_1= mysqli_query($link, "SELECT * FROM studentdetails, criteria WHERE studentdetails.StudentID = criteria.StudentID ORDER BY gpa ASC"); Quote Link to comment https://forums.phpfreaks.com/topic/242607-i-am-not-able-to-post-why/#findComment-1246525 Share on other sites More sharing options...
ferlicia Posted July 25, 2011 Author Share Posted July 25, 2011 sorry there is still codes after the form in the same page <?php include 'dbFunctions.php'; $fields = mysqli_list_fields("fyp", "criteria", $link); there is an error in this line: Fatal error: Call to undefined function mysqli_list_fields() $columns = mysqli_num_fields($fields); ?> <form method="post" action="doSelectCriteria.php">; <select name = criteria>; <?php for ($i = 0; $i < $columns; $i++) { echo "<option value='".mysqli_field_name($fields, $i)."'>"; echo mysqli_field_name($fields, $i); } echo "</select>"; ?> <input name="btnsubmit" value="Submit" type="submit"></p>; </form> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/242607-i-am-not-able-to-post-why/#findComment-1246532 Share on other sites More sharing options...
darkfreaks Posted July 25, 2011 Share Posted July 25, 2011 there is no mysqli function called mysqli_list_fields do you mean mysql_list_fields Quote Link to comment https://forums.phpfreaks.com/topic/242607-i-am-not-able-to-post-why/#findComment-1246539 Share on other sites More sharing options...
ferlicia Posted July 25, 2011 Author Share Posted July 25, 2011 i vane changed it to mysql, then there is still error Warning: mysql_list_fields() expects parameter 3 to be resource, object \ Quote Link to comment https://forums.phpfreaks.com/topic/242607-i-am-not-able-to-post-why/#findComment-1246540 Share on other sites More sharing options...
darkfreaks Posted July 25, 2011 Share Posted July 25, 2011 cant mix MYSQL and MYSQLI commands try using mysqli_fetch_fields Quote Link to comment https://forums.phpfreaks.com/topic/242607-i-am-not-able-to-post-why/#findComment-1246544 Share on other sites More sharing options...
ferlicia Posted July 25, 2011 Author Share Posted July 25, 2011 i am trying to print the table name from the database. how can i do it since i am not able to do it that way Quote Link to comment https://forums.phpfreaks.com/topic/242607-i-am-not-able-to-post-why/#findComment-1246661 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.