Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6827139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:13:52+00:00 2026-05-26T22:13:52+00:00

So I have db table>schools and a column in this table named metro. In

  • 0

So I have db table>”schools” and a column in this table named “metro”.
In “metro” i have strings like that “Station Name 1, Station Name 2, Station-Name 5”

I’m doing now a search form with select metro stations, so my code look like this:

<select name="categoryID">
<? 

$metro_sql=mysql_query("SELECT metro FROM schools");
while($metro=mysql_fetch_array($metro_sql)){
    $metro_pieces = explode(", ", $metro['metro']);
        foreach (array_unique($metro_pieces, SORT_REGULAR) as $metro_all) {
             echo "<option value=\"".$metro_all."\">".$metro_all."</option>\n  ";
    }
}

And the result:
Metro Station 1
Metro Station 2
Metro Station 3
Metro Station 1
Metro Station 4
Metro Station 5
etc.
What I’m doing wrong?
p.s. sorry for my english.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:13:52+00:00Added an answer on May 26, 2026 at 10:13 pm

    I would suggest a better database design.

    CREATE TABLE school (
      school_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
      name VARCHAR(255)
    );
    
    CREATE TABLE station (
      station_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
      name VARCHAR(255)
    );
    
    CREATE TABLE metro (
      school_id INT NOT NULL,
      station_id INT NOT NULL,
      UNIQUE INDEX (school_id, station_id)
    );
    

    You create schools in school and stations in station. When you need to link a school to a station, you add a record to metro. This makes the database normalized.

    When you then need to get the stations, you simply do a:

    SELECT station.* 
    FROM metro
    INNER JOIN station
    ON metro.station_id = station.station_id
    WHERE metro.school_id = $school_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user table that has many columns, it looks roughly like this:
I have table and this table contain result column with some entries. I just
I have a hibernate mapping as follows: <hibernate-mapping> <class name=kochman.elie.data.types.InvoiceTVO table=INVOICE> <id name=id column=ID>
I have a database which has one table, Schools. This table also has latitude
I have table with around 70 000 rows. There is 6000 rows that i
I have table with 300 000 records (MyISAM). I get record from this table
I have table of data that is sorted as follows: Item | Sample |
My table has few fields with an amount column of type decimal. This column
I have two tables one named Person , which contains columns ID and Name
My MySQL DB looks like this **table_schools** id | name 1 | school_1 2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.