Jump to content

can this be done?


Ameslee

Recommended Posts

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!
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

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 Structure
Name: services
-------------------------------
id        exhibit_id        services
-------------------------------
1          1                    Employment<>Accommodation<>Education
2          2                    Employment<>Personal support

Note 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...
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

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 Exhibit
2        Second Exhibit

Then on a page called like list-edit.php have something like this:

[code=php:0]
//First we will build the table header... Basic HTML
echo <<<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 them

while($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 table
echo "</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?
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.