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 9266865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:24:58+00:00 2026-06-18T14:24:58+00:00

I know this is probably something simple, but I’m new to PHP and MySQL

  • 0

I know this is probably something simple, but I’m new to PHP and MySQL development so I’d appreciate some help. I couldn’t find an existing example on Stack that I could understand so I’m posting it out there in hopes of some guidance.

I have a database table with address information in it. I’ve split the address into two fields, house_number and street_name, and what I need to do is display the information grouped by street name, then ordered by house number.

I’ve mocked up an example of what I need the page to look like. It has even addresses in the first column and odd addresses in the second column. I’m using the Twitter Bootstrap for formatting.

$address = mysql_query("SELECT id, house_number, street_name, full_address FROM resident WHERE neighborhood_id = $neighborhood_id order by street_name, house_number;");

What it should look like

enter image description here

HTML CODE BELOW:

<!--STREET GROUPING -->
    <div class="row-fluid">
        <div class="span12">
        <h3>ASHTON PARK WAY</h3>
        </div>
    </div >

    <div class="row-fluid">
        <div class="span6"><!-- EVEN ADDRESSES -->
            <a href="#" class="btn btn-large btn-white btn-block">18102 Ashton Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18104 Ashton Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18106 Ashton Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18108 Ashton Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18110 Ashton Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18112 Ashton Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18114 Ashton Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18116 Ashton Park Way</a>
        </div><!-- END EVEN ADDRESSES -->

        <div class="span6"><!-- ODD ADDRESSES -->
            <a href="#" class="btn btn-large btn-white btn-block">18101 Ashton Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18103 Ashton Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18105 Ashton Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18107 Ashton Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18109 Ashton Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18111 Ashton Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18113 Ashton Park Way</a>
        </div><!-- END ODD ADDRESSES -->

    </div>
<!-- END STREET GROUPING -->

    <hr>

<!--STREET GROUPING -->
    <div class="row-fluid">
        <div class="span12">
        <h3>HAMDEN PARK WAY</h3>
        </div>
    </div >

    <div class="row-fluid">
        <!-- EVEN ADDRESSES -->
        <div class="span6">
            <a href="#" class="btn btn-large btn-white btn-block">18102 Hamden Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18104 Hamden Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18106 Hamden Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18108 Hamden Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18110 Hamden Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18112 Hamden Park Way</a>
        </div>
        <!-- END EVEN ADDRESSES -->

        <!-- ODD ADDRESSES -->
        <div class="span6">
            <a href="#" class="btn btn-large btn-white btn-block">18101 Hamden Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18103 Hamden Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18105 Hamden Park Way</a>
            <a href="#" class="btn btn-large btn-white btn-block">18107 Hamden Park Way</a>
        </div>
        <!-- END ODD ADDRESSES -->

    </div>
<!-- END STREET GROUPING -->
  • 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-06-18T14:24:59+00:00Added an answer on June 18, 2026 at 2:24 pm

    I’m not sure what you’re looking to change here. The Group By function is SQL is probably not going to do what you think it should do here. It’s generally best used in a context, something like

    SELECT count(invoicesTotal),sum(invoicesTotal) FROM invoices GROUP BY customer
    

    On your database, run

    SELECT * FROM resident GROUP BY street_name
    

    You’ll only get back the first record found that matches street_name, which is not what you’re looking for in this context.

    I think the way you’re going out about it now with ORDER BY street_name, house_number is the best, and use a foreach to build your table.

    Also don’t use the mysql extension. Use mysqli extension. mysql is getting deprecated very soon. From a beginner’s perspective there is not much difference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this is probably something simple but I can't seem to find anything
I know this is probably something simple, but I can't figure it out. When
I know this is probably dead simple, but I've got some data such as
I know this is probably something stupid-simple, but I recently added a folder to
This is something stupid I probably should know, but Googling fails me: When compiling
I know this probably really simple but Im not sure what im doing wrong...
I know this is probably a very simple question but how would I do
ok, I know this is probably going to be something really easy but I
Okay, I know this is probably dead simple, but I can't seem to find
I know this is probably something so simple that I am just not able

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.