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

The Archive Base Latest Questions

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

I know I have coded this incorrectly, but cannot seem to find a way

  • 0

I know I have coded this incorrectly, but cannot seem to find a way to correct it. The aim, is to have a dropdown displayed populated with results from mysql database. It is currently displaying a dropdown for every address. I know why this is happening but cannot seem to correct it. Should the echo be out of the while loop? or is the placement correct but it is wrong somewhere else? would be gratful if someone could check it and inform me where i AM GOING WRONG WITH IT. Many thanks.

<?php
    $customer = mysql_real_escape_string( $_GET["customer"] );         
    $con = mysql_connect("localhost","root","");
    $db = "sample";
      if (!$con)
        {
        die('Could not connect: ' . mysql_error());
        }

        mysql_select_db($db, $con);
        $query_rs_select_address2 = sprintf("SELECT * FROM company_com where idcode_com = '$customer'");
        $rs_select_address2 = mysql_query($query_rs_select_address2, $con) or die(mysql_error());
        $row_rs_select_address2 = mysql_fetch_assoc($rs_select_address2);
        $totalRows_rs_select_address2 = mysql_num_rows($rs_select_address2);

        while ($row_rs_select_address2 = mysql_fetch_assoc($rs_select_address2))
            {  
        $address=$row_rs_select_address2['address1_com']. " ". $row_rs_select_address2['address2_com']. " ". $row_rs_select_address2['address3_com']. " ". $row_rs_select_address2['town_com']. " ". $row_rs_select_address2['postcode_com'];
        echo '<select name="customer">'.'<option value="">Select delivery address</option>'.'<option value="address">'.$address.'</option>'.'</select>';

            }

?>
  • 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-23T22:26:16+00:00Added an answer on May 23, 2026 at 10:26 pm

    Try this:

    echo '<select name="customer">';
    echo '<option value="">Select delivery address</option>';
    while ($row_rs_select_address2 = mysql_fetch_assoc($rs_select_address2))
    {  
        $address=$row_rs_select_address2['address1_com']. " ". $row_rs_select_address2['address2_com']. " ". $row_rs_select_address2['address3_com']. " ". $row_rs_select_address2['town_com']. " ". $row_rs_select_address2['postcode_com'];
        echo '<option value="address">'.$address.'</option>';
    }
    echo '</select>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code, I know I'm missing something but don't know what. It
As you may know, when we have this code in Javascript : function getName()
Hey, I don't have any code because I don't know how to do this.
I have this piece of code that is giving me trouble. I know all
I know this is similar to many other questions on S.O. but none of
I know this question has been asked to death here, but I am unable
I know there are a lot of these topics around but none seem to
I have this code will work in multithreaded application. I know that immutable object
I know this question has been asked in several variations before, but my question
I have dynamic CMS-driven (custom rolled, I know, wheels, etc. but not my decision!)

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.