Ameslee Posted December 20, 2006 Share Posted December 20, 2006 code so far:[code]<select name="services"> <option value="Employment">Employment</option> <option value="Government">Government</option> <option value="Training">Training</option> <option value="Rehabilitation">Rehabilitation</option> <option value="Accomodation">Accomodation</option> <option value="Sport and leisure">Sport and leisure</option> <option value="Information">Information</option> <option value="Personal support">Personal support</option> <option value="Education">Education</option> <option value="Transition to Work">Transition to Work</option> <option value="Community Participation">Community Participation</option> </select>[/code]I have maintenance pages, to maintain a website. The user will enter the fields required. I didnt do a drop down list on the maintenance page coz they might have more than one service available to that record. so the user enters a service1, service2 etc.i want to be able to, on the website, anyone come in and open the drop down list, select and option (service). Then from there looks up the services field, and select all records that has the option selected in that field.does this make sense?is this 2 complicated, should i just stick to selecting records through the a-z list. i was really just giving the user options, if they didnt know what they were looking for. is it easier to do a keyword search that looks up the field for what is entered?can anyone help me? thanks! Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted December 20, 2006 Share Posted December 20, 2006 I am not quite sure I get what you mean. Quote Link to comment Share on other sites More sharing options...
Ameslee Posted December 20, 2006 Author Share Posted December 20, 2006 ok, what do u want to know? Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted December 20, 2006 Share Posted December 20, 2006 so your saying you have a form. and they select an option from the above drop-down list and hit submit. It will then take them to a page where it lists all the records for that option...? Quote Link to comment Share on other sites More sharing options...
Ameslee Posted December 20, 2006 Author Share Posted December 20, 2006 yeah basically, i just dont know if code can be written to look up a field that has more than one item in it Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted December 20, 2006 Share Posted December 20, 2006 what exactly do you mean, "more that one item in it"?i'm going a bit slow today... :) Quote Link to comment Share on other sites More sharing options...
Ameslee Posted December 20, 2006 Author Share Posted December 20, 2006 thats ok, me 2!The table to begin with, holds information about exhibits at an expo. One of the fields is services, the field on the maintenance page is a text area, so the admin person, who ever gets the job of maintaining the site will enter what ever the services of that exhibit are. At times there will be more than one service that the exhibit has to offer. so i am not sure how to go about the code, from the selection from the drop down menu to searching of that field for the particular selection from the drop down menu. and then displaying all records that have that service that was selected in the drop down menu.does this make more sense? Quote Link to comment Share on other sites More sharing options...
matto Posted December 20, 2006 Share Posted December 20, 2006 If you are referring to querying an SQL database an displaying records something like this could be done..SQL Code:[code]select * from table where service IN('Employment','Government','Training')[/code]Not sure if this is what you mean.... Quote Link to comment Share on other sites More sharing options...
Ameslee Posted December 20, 2006 Author Share Posted December 20, 2006 actually that might work, just dont know how to work it with the drop down menu Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted December 20, 2006 Share Posted December 20, 2006 man that sounds so confusing, i read that like 10 times and i am still confused. lol. so... let me get this straight... each exhibit will or will not have all the options listed above. some might only have a couple...if this is stored in a database then that would be good. you could do something like this.Table StructureName: services-------------------------------id exhibit_id services-------------------------------1 1 Employment<>Accommodation<>Education2 2 Employment<>Personal supportNote how I am using <> inbetween the different services. you could use commas or something but i like using <>, we'll make an array out of it...Then when selecting:[code=php:0]if(!isset($_GET['id'])){ $id = 1; }else{ $id = $_GET['id']; } //Selecting an exhibit ID. You might want to make a page that lists all the exhibits...$services = mysql_result(mysql_query("SELECT `services` FROM services WHERE `exhibit_id`='{$id}'"), 0);$services = explode("<>", $services);echo <<<html<select name="services">html;foreach($services as $value){if($value != ""){ //just in case there are blanks...echo "<option value='{$value}'>{$value}</option>";}}echo <<<html</select>html;[/code]is that something like the first part... i think i might've gone way off track... Quote Link to comment Share on other sites More sharing options...
Ameslee Posted December 21, 2006 Author Share Posted December 21, 2006 omg im so confused now, but ill give it ago, when u say //Selecting an exhibit ID. You might want to make a page that lists all the exhibits... what do you mean by this. and i already have php on this page so should i start a new lot of continue with what i already have.and does the drop down list need a submit button or does it automatically work once something is selected? Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted December 21, 2006 Share Posted December 21, 2006 that will just list the options... sorry for confusing you, i tried adding commments.the bit that says about Selecting an exhibit ID...I am grabbing it from the url... so if you entered something like: http://www.yoursite.com/edit.php?id=2 it would select the services for the exhibit ID 2 in that table above...So what i mean by create a page with all the exhibits i mean like, have a table that looks like this:Name: exhibits-----------------------------id exhibit-----------------------------1 First Exhibit2 Second ExhibitThen on a page called like list-edit.php have something like this:[code=php:0]//First we will build the table header... Basic HTMLecho <<<html<table border="0" width="100%" cellpadding="1" cellspacing="0"><tr><td>ID</td><td>Name</td></tr>html;$query = mysql_query("SELECT * FROM exhibits");if(mysql_num_rows($query) == 0){ //There are no exhibits...echo <<<html<tr><td colspan="2">Oops! No exhibits found!</td></tr>html;}else{ //There is some exhibits... Run a while loop to display themwhile($r = mysql_fetch_array($query)){echo <<<html<tr><td>{$r['id']}</td><td><a href="edit.php?id={$r['id']}">{$r['exhibit']}</td></tr>html;}}//Close the tableecho "</table>";[/code]That will list all the exhibits with links to the edit page wheere it lists all the services for that exhibit... :)Am i on the right track? Quote Link to comment Share on other sites More sharing options...
Ameslee Posted December 21, 2006 Author Share Posted December 21, 2006 ok i already have a page that lists the exhibit.[code]<?php $hostname = localhost; $username = greenac_Admin; $password = greenac; $conn = mysql_connect($hostname, $username, $password) or die(mysql_error()); $connection = mysql_select_db("greenac_VORNExpo", $conn); $query = "SELECT * FROM `exhibits` WHERE serviceid='{$_GET['id']}'"; if ($mysql_result = mysql_query($query,$conn)) { if (mysql_num_rows($mysql_result) > 0) { $row=mysql_fetch_row($mysql_result); echo("<table width=100%><tr><td width=20%><b>Exhibit:</b><td width=35%>$row[1]"); echo("<tr><td width=20%><b>Located:</b><td width=35%>$row[2]"); echo("<tr><td width=20%><b>Services:</b><td width=35%>$row[3]"); echo("<tr><td width=10%><b>Contact Person:</b><td width=35%>$row[4]"); echo("<tr><td width=10%><b>Contact Number:</b><td width=35%>$row[5]"); echo("<tr><td width=10%><b>Category:</b><td width=35%>$row[6]"); } else { echo "No results found"; } } else { echo "Query failed: ". mysql_error() . ": $query"; } ?>[/code][quote]I am grabbing it from the url... so if you entered something like: http://www.yoursite.com/edit.php?id=2 it would select the services for the exhibit ID 2 in that table above...[/quote] that is right.the table is already set up and has the fields that are displayed above.edit: I have confused myself soo much, that i am talking about the wrong field, its actually the category field Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted December 21, 2006 Share Posted December 21, 2006 so you want it to list all the exhibits when they select a service because i am confused. lol. :D Quote Link to comment Share on other sites More sharing options...
Ameslee Posted December 21, 2006 Author Share Posted December 21, 2006 yep thats right, when they select a category, sorry confused myself , its actuallt the category field. so yeah a category is selected all exhibits thats have that category are displayed Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted December 21, 2006 Share Posted December 21, 2006 ahhh... i am following you no. all my code was basicly wrong then. lol. :Dso the services field in the exhibit table, how is that set out? how is the information entered into that field? (in the actual mysql table) Quote Link to comment Share on other sites More sharing options...
Ameslee Posted December 21, 2006 Author Share Posted December 21, 2006 its just typed in, and remember its the category field. Do you think i should make the category field on the maintenance pages a drop down list, identical to the one displayed on the website, and say to the ppl that want it on the site, that its too complicated to do it the way they want Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted December 21, 2006 Share Posted December 21, 2006 yes but i mean, is there multiple categories (exhibits, i think, i am confused) in the services field...like:Accommodation,Education etc.... All in the one service field...? Quote Link to comment Share on other sites More sharing options...
Ameslee Posted December 21, 2006 Author Share Posted December 21, 2006 im actually splitting something up to make it easier, i noticed you have msn, i have added you to mine, would that be easier Quote Link to comment 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.