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

  • Home
  • SEARCH
  • 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 6976285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:28:36+00:00 2026-05-27T17:28:36+00:00

It was working before and maybe someone made changes to the code and I

  • 0

It was working before and maybe someone made changes to the code and I cant detect the problem after much debugging so hopefully someone can help.

I have an html form that lets a user choose a set of option and then on form submit, POSTS these options in an array which works perfectly fine. Then I am writing the elements of an array to a MySQL table and this is where the problem occurs. My code was working fine before but now its all weird. The outputs mix up for some reason.

Below is the array values passed and then the output below the arrays.

enter image description here

Here is my code that writes the array values to MySQL:

error_reporting(-1);
$arr=$_POST["itemsToAdd"];

$cal=$_POST["calendar"];

print_r($arr);

// Make a MySQL Connection


//empty table first to remove any previous old on-calls stored.
$query = "truncate table ProdOnCallSetup";
if(mysql_query($query)){
}
else{
}




foreach ($arr as &$value) {

// Insert a row of information into the table "ProdOnCallSetup"
mysql_query("INSERT INTO ProdOnCallSetup
(Email) VALUES('$value') ") 
or die(mysql_error());

}

Here is the code giving the output or displaying the rows in MySQL:

<ol class=”list_style”>

    <?php
//make MySQL connection

    $query = "SELECT * FROM ProdOnCallSetup";

    $result = mysql_query($query) or die(mysql_error());


    while($row = mysql_fetch_array($result)){
        echo "<li>".$row['Email']."</li>";
        echo "<br />";
    }


    ?>

</ol>

See the problem here? Even though I write them in the correct order in MySQL when I display them the order mixes up. Order is Justin, Achau, Chellatamby but when I echo is out from the DB its Achau, Chellatamby, Justin

  • 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-27T17:28:37+00:00Added an answer on May 27, 2026 at 5:28 pm

    Unless you specifically use an ORDER BY clause in your SELECT statement, the order in which rows are returned is indeterminate and may change…. it doesn’t matter what order you added the records in, this is irrelevant… use ORDER BY…

    SELECT * FROM ProdOnCallSetup ORDER BY Email 
    

    (or whatever column id you want to order them on)

    If you want to order them in the order you added them to the database, you’ll need an autoincrement column on the table, and order by that column

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

Sidebar

Related Questions

So basically this code was working fine before. I had some computer issues and
My code was working absolutely fine before the launch of iPhone SDK 3.0 ,
Maybe someone can explain this behavior. Sometimes I will do an SVN update, and
Ok, this is bit of an obscure question, but hopefully someone can help me
Strangely I had this working before but I reinstalled my system, upgraded to w7
I have a project on github that I have been working on before. However,
I have used code like this: http://msdn.microsoft.com/en-us/library/dw70f090.aspx to access database before when working in
A project I'm working on requires serializing a data structure before shutting down and
I'm working on better understanding Linq-to-SQL before using on a real project, so I'm
I asked this question before and got a great working answer. what is the

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.