Jump to content

Recommended Posts

Hi

 

I'm a newbie and have only been learning for four weeks or so. I am practicing what i've read and so am creating my first web application

 

I'm designing a system where venues need to register, I have mostly completed the registration page but am struggling with one particular aspect.

 

The database consists of the tables:

 

venue(Where foreign key=AreaID)

area(AreaID, AreaName, AreaRegion)

 

When venues register they must select an AreaID. At the moment I have dynamically created a drop down box that is populated by querying the area table in mysql. It sorts the option by AreaName and the values correspond to the AreaID.

 

Whilst I was initially happy, I've realised that the sheer number of areas mean it will have to be sorted by AreaRegion. I think optgroup can be used to achieve this. The AreaRegion column is type enum('Scotland', 'Wales',....) with more regions to be added.

 

I've done a little research, but have ended up more confused than before! Any suggestions would be much appreciated. My code at the moment:

 

<p><b>Select Area:</b><select name="areaid">

<?php

$query1 = "SELECT AreaID, AreaName from area ORDER BY AreaName ASC";
$result1=@mysql_query($query1);

while ($row = @mysql_fetch_array($result1)) {
print '<option value="' . $row['AreaID'] . '">' . $row['AreaName'] . '</option>';
}
?>

 

</p>

</select>

 

 

Thanks in advance,

 

Daniel

Thanks for the quick reply.

 

I put 'SELECT * FROM area INNER JOIN venue ON area.AreaID = venue.AreaID ORDER BY AreaRegion DESC' but it didn't work.

 

From the examples i've seen on the net (which confused me greatly) I'm guessing my code is going to need a complete revamp, not just the query.

 

Once again thanks in advance, any suggestions are much appreciated.

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.