Search the Community
Showing results for tags 'select box'.
-
Hi Pals. I have a select option named doctor that i need to depend on the another select option named field, just like in Months and days where February shows 29 days in the days select option when clicked. The only difference here is that my data source is from mysql database instead of just html.
- 7 replies
-
- select box
- mysql
-
(and 1 more)
Tagged with:
-
Guys, need some help.. Right now i have a login page with select box option.. I have create several other page (admin_page.php, student_page.php, parents_page.php) to link with the option in the select box.. So what im asking now is how to link the selected option to their page respectively with the username and pass correct? Here is the login page looks like.. http://i272.photobucket.com/albums/jj178/r1nk_2008/lol_zpsa54db359.png <html> <head> <title> Login Form </title> </head> <body> <div style="width: 200px; margin: 200px auto 0 auto;"> <form method='post' action='login.php'> <table width='400' border='5' align='center'> <tr> <td align='center' colspan='5'><h1>Member Login</h1></td> </tr> <tr> <td align='center'>Username:</td> <td><input type='text' name='username' /></td> </tr> <tr> <td align='center'>Password:</td> <td><input type='password' name='pass' /></td> </tr> <tr> <td></td> <td align='left'> <select name="type" id="type"> <option value="0" selected="selected">Select user type</option> <option value="admin">Admin</option> <option value="student">Student</option> <option value="lecturer">Lecturer</option> <option value="parents">Parents</option> </select> </td> </tr> <tr> <td colspan='5' align='center'><input type='submit' name='login' value='Log In' /></td> </tr> </table> </form> </body> </html> <?php mysql_connect("localhost","root",""); mysql_select_db("student_attendance"); if(isset($_POST['login'])){ $username = $_POST['username']; $password = $_POST['pass']; $type = $_POST['type']; $check_user = "select * from users where username='$username' AND pass='$password' AND type='$type'"; $run = mysql_query($check_user); if(mysql_num_rows($run)>0){ echo "<script>window.open('admin_page.php','_self')</script>"; } else { echo "<script>alert('Username, password or user type is incorrect!')</script>"; } } ?>
-
Hey, i got another question. Ok so far i have a table called users (id, name, username, pass, type) and here is my coding so far.. <html> <head> <title> Login Form </title> </head> <body> <form method='post' action='login.php'> <table width='400' border='5' align='center'> <tr> <td align='center' colspan='5'><h1>Login Form</h1></td> </tr> <tr> <td align='center'>Username:</td> <td><input type='text' name='username' /></td> </tr> <tr> <td align='center'>Password:</td> <td><input type='password' name='pass' /></td> </tr> <tr> <td align='center'> <select name="type" id="type"> <option value="0 selected="selected">Select user type</option> <option value="admin">Admin</option> <option value="student">Student</option> </select> </tr> <tr> <td colspan='5' align='center'><input type='submit' name='login' value='Log In' /></td> </tr> </table> </form> </body> </html> <?php mysql_connect("localhost","root",""); mysql_select_db("student_attendance"); if(isset($_POST['login'])){ $username = $_POST['username']; $password = $_POST['pass']; $type = $_POST['type']; $check_user = "select * from users where username='$username', pass='$password' AND type='$type'"; $run = mysql_query($check_user); if(mysql_num_rows($run)>0){ echo "<script>alert('You are logged in')</script>"; } else { echo "<script>alert('username,password or user type is incorrect!')</script>"; } } ?> And when i viewed it looks like this.. http://i272.photobucket.com/albums/jj178/r1nk_2008/prob_zpsd907ed84.png So my questions are :- -how to make the select box option to the right side, below the password form ? -how to fix the error so that when i enter correct username, pass and type it says "you are login" ?
-
I am trying to update the second select box 'subcategory_id' but I don't know how to return the query values back to the control/twig template. All of the examples I have seen echo back html from a option while loop. Should I be echo back the html as per other common examples or is there a more twig compliant way to do this, maybe returning an array variable. Thanks in advance, James catalogues.php <script> $('#category_id').change( function() { checkCategory(); // checks value and enables/disables subcategory control var catid = $(this).val(); var dataString = 'catid='+catid; $.ajax ({ type: "POST", url: "catalogues.php", data: dataString, cache: false, success: function() { $("#subcategory_id")..........; // ????? } }) }); </script> <?php if(isset($_POST['catid'] )) { $catid=$_POST['catid']; $sql_subcategory = "SELECT catalogues_categories.id, catalogues_categories.category, catalogues_categories.parent_id, catalogues_categories.inuse FROM catalogues_categories WHERE catalogues_categories.parent_id = {$catid} AND catalogues_categories.inuse = 1 ORDER BY catalogues_categories.category ASC"; $query_subcategory = $conn->query($sql_subcategory); $results_subcategory = $query_subcategory->fetchAll(); } else { $results_subcategory = null; } ?>
-
Hi I am an absolute starter in php and have little to no knowledge on JS, ajax or any other scripting tool. I thought that I will be able to write a whole project based on little php knowledge that I have. But am stuck at one place. I have one select box which contains the list of projects. On the basis of project selected I need to filter out a list of equipment from the equipment table and display it in another select box. This all needs to be done before the Submit. Having searched in google for some help I find that it seems to be simply not possible with php. I need to put in some JS or AJAX code to fulfill this task. Can anybody share with me any sample code or any solutions for this problem. Project and Equipment table are related on Project Code. regards sandy