krishnaeecs Posted August 18, 2008 Share Posted August 18, 2008 I am designing a website using php I want to put list of colleges of all states in country and all courses in that colleges. So i want to use SELECT option for my best..... the first one is for COURSE, and next is STATE. (like........ Select Course Select State submit) whenever somebody selects the belonging course in required state i have to display the list of that colleges. i am confused for managing the 2 SELECT fields at same time.... i have tried this using arrays................. Please give me the code, Here i am giving all states and courses list COURSES: M.B.A. M.C.A. B.TECH. M.TECH. B.ED. B.PHARMACY. STATES: Andhra Pradesh Arunachal Pradesh Assam Bihar Chandigarh Chhattisgarh Dadra & Nagar Haveli Lakshadweep Madhya Pradesh Maharashtra Manipur Meghalaya Mizoram Nagaland Orissa Daman & Diu Delhi Goa Gujarat Haryana Himachal Pradesh Jammu & Kashmir Jharkhand Karnataka Kerala Pondicherry Punjab Rajasthan Sikkim Tamil Nadu Tripura Uttar Pradesh Uttaranchal West Bengal for example when we select M.B.A. and Andhra Pradesh........... I want to display that belonging page(i.e., M.B.A. colleges in Andhra Pradesh State) I deigned all the required pages in HTML. Link to comment https://forums.phpfreaks.com/topic/120230-about-form-in-php/ Share on other sites More sharing options...
uniflare Posted August 18, 2008 Share Posted August 18, 2008 So, Each College has its own courses. There are different colleges in each state. MySQL will make this a piece of cake. eg; (On the result page, after you click submit). <?php mysql_connect("...","...","..."); mysql_select_db("..."); $state = mysql_escape_string($_POST['state']); $course = mysql_escape_string($_POST['course']); $query = mysql_query("SELECT `collegename` FROM `colleges` WHERE `state`='".$state."' AND `course` LIKE '%".$course."%' "); While($Row = mysql_fetch_assoc($query)){ print_r($Row); } mysql_close(); ?> to explain the PHP: Connect to MySQL and Select the Database your working with. mysql_escape_string() converts unwanted characters from un-safe sources into safe mysql code that can be used in queries like this. `colleges` is the Table Name inside the Database. `collegename` is a cloumn or "field" inside that table. (along with `state` and `course`) The Structure should be as: Table colleges `id` `name` `state` `course` `address` Example: 0 College of Alabama Alabama M.B.A. M.C.A. 243 some long road, B.TECH. M.TECH. Some city, B.ED. B.PHARMACY. Alabama So the "Course" field would hold every course that college deals with. along with other details like its state and address etc. So when you use "Where `state`='%Alabama%' " you are filtering all colleges inside alabama. Then when you use "Where `course` LIKE '%Coursename%' " you are filtering out anything with Coursename found in the `course` field. the % symbol is a "Wildcard" so if you searched for "course" and there was "somecourse" it would find "somecourse" to be a match. Hope this helps. Link to comment https://forums.phpfreaks.com/topic/120230-about-form-in-php/#findComment-619397 Share on other sites More sharing options...
krishnaeecs Posted August 20, 2008 Author Share Posted August 20, 2008 Thank you most probably my problem is solved....... i have another doubt. on result page i want to display the regarding list as a table.please help me...... ------------------------------------------------------------------------------- how can i view my total database or table, after modify orinserting the values in it. ------------------------------------------------------------------------------- And,,,,,,,,,,,,,, I want to know ..........who is opening my site ..........what content he is downloading ..........page reviews ..........total clicks on my site and each page ..........totally i mean counter and that also visible to only administrator means mine..... can you please help me on this topic...... Link to comment https://forums.phpfreaks.com/topic/120230-about-form-in-php/#findComment-621421 Share on other sites More sharing options...
uniflare Posted August 21, 2008 Share Posted August 21, 2008 What you are asking is a lot, and its all extremely simple. I'm afraid myself personally cannot write all this code for you or repeat what numerous tutorials all over the web are teaching (a little busy ). Maybe someone else on here has the extra time and effort . It sounds like you are very new to PHP. I would suggest to you to look at some basic tutorials on here (phpfreaks) or even elsewhere. Find a tutorial on how to make a simple MySQL Guestbook. Trust me it's so easy once you do it you will realise, oh hey, i can do all these thousands of other tasks the same way! PHP is very good like that and very easy to learn. I'm sorry i could not help you further, but good luck! Link to comment https://forums.phpfreaks.com/topic/120230-about-form-in-php/#findComment-622134 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.