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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:04:09+00:00 2026-06-01T16:04:09+00:00

I am trying implement a search activity which gets data from a mysql table

  • 0

I am trying implement a search activity which gets data from a mysql table based on a search.

I want to write a PHP script to use the string entered into the EditText and get the adjacent cell.

For example, Imagine there are two columns of the mysql table: Firstname and surname; I would like to be able to get the surname by searching the Firstname (Entering the Firstname into the EditText. I know this may require a SELECT Surname FROM Names WHERE ... query but how do I indicate the variable from my Java class?

The PHP script so Far:

<?php
mysql_connect("localhost","root","");
mysql_select_db("androidapp");
$sql=mysql_query("SELECT surname WHERE $get'fname'");
while($row=mysql_fetch_assoc($sql)) $output[]=$row;
print(json_encode($output));
mysql_close();
?>

Also, is the HttpGet method appropriate or HttPost method to do this, the result should display the surname in a TextView

  • 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-01T16:04:10+00:00Added an answer on June 1, 2026 at 4:04 pm

    i assume you want to send and receive data from php to java (android) through http post or http get. correct me if i am wrong.

    basically what you want php to return is the row that matches the first name in the table.

    mysql_connect("localhost","root","");
    
    mysql_select_db("androidapp");
    
    $fname = mysql_real_escape_string($_POST['fname']);
    
    $result = mysql_query("SELECT surname FROM names WHERE fname = '$fname'");
    
    //if you want only one record then
    $row = mysql_fetch_array($result);
    
    echo json_encode($row);
    
    mysql_close();
    

    always remember to escape the data for any sql injection with php’s mysql_real_escape_string() function. ans also i would prefer HTTP POST.

    from your android application you will have to send a http request to the server where the PHP script is.

    hope this helps you

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

Sidebar

Related Questions

I am trying to implement a djapian based full text search for searching user
I'm trying to implement popup search window in a PHP project. I included JQuery
I'm trying to implement a search method, which returns a index of a object
I'm trying to implement a search box using php and jquery (the seach results
I'm trying to implement search code in my CoreData-based iPhone app. I'm not sure
I am trying to implement Listview with search functionality, in which i am successful
I'm trying to implement search functionality in my app, which is very basic at
I am trying to implement customized search in my application. The table structure is
I'm trying to implement search in my app. There are two Core Data entities,
im trying to implement local search api, to retreive data for shops and other

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.