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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:39:08+00:00 2026-06-01T15:39:08+00:00

I am sending 2 arraylist from android to php through url . Mysql contains

  • 0

I am sending 2 arraylist from android to php through url .
Mysql contains test table with two columns menuimage, menuname. I want to update menu name only but it is updating only first row of menuname in mysql database

Tried so far-

          <?php
$old_menu_names=explode(',',preg_replace('/^.*\[(.*)\].*$/','$1',trim($_POST['menuname'], '[]')));
$new_menu_names=explode(',',preg_replace('/^.*\[(.*)\].*$/','$1',trim($_POST['editmainmenu'], '[]')));
mysql_connect("localhost", "root", "MobixMySQL");
mysql_select_db("cozydine");
foreach ($old_menu_names as $key => $old_name) {
    $new_name = mysql_real_escape_string($new_menu_names[$key]);
    $old_name  = mysql_real_escape_string($old_menu_names[$key]);
    echo $new_name;
    mysql_query("UPDATE `mainmenu` SET `menuname` = '$new_name' WHERE menuname = '$old_name'")
    or die('Error' . mysql_error());
    echo "Updated";
   }
 ?>
  • 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-01T15:39:10+00:00Added an answer on June 1, 2026 at 3:39 pm

    Thats because their in only one old name in the db that is now replaced with new name. if you want to update all the values of rows with new do something like this

    "UPDATE `mainmenu` SET `menuname` = '$new_name' WHERE menuname IN ($unexploded_old_menu_names)"
    

    EDITED

    in your loop instead of using key for new name use a counter

    $i = 0;
    foreach ($old_menu_names as $key => $old_name)
    {
    $new_name = mysql_real_escape_string($new_menu_names[$i]);
    $old_name  = mysql_real_escape_string($old_menu_names[$key]);
    echo $new_name;
    mysql_query("UPDATE `mainmenu` SET `menuname` = '$new_name' WHERE menuname = '$old_name'")
    or die('Error' . mysql_error());
    echo "Updated";
    $i++;
    

    }

    Because key might not be working for new names array.

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

Sidebar

Related Questions

I am sending post request from android to the url using httpclient like this
M sending the parameters from the jsp page, the code is <s:url id=url action=searchAction>
I have a Problem with Parcelable Data in an ArrayList sending via two Activities
I am sending data from android to a Generic handler .ashx page in asp.net
I am trying sending data from android application (with emulator) to web server (a
I have written a code in android as as well as in php..while sending
I am sending a POST request to a Server from my Android Application. The
I need a little help with sending an HttpUrlConnection from my android application. Till
Sending a message from the Unix command line using mail TO_ADDR results in an
Sending a mail through my windows application to a person asking him to log

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.