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

The Archive Base Latest Questions

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

I currently have this code which reads the first field in a database record

  • 0

I currently have this code which reads the first field in a database record which is specified by the user (‘myid’ being a text field which accepts a number) and prints it in one of the fields of a front end form.

How do I make a JSON array of all of the fields in the database and then print them to the relevant form field? Thanks

Back-End Code

 $id = $_POST['id'];

 $query = "SELECT * FROM Customers WHERE ID = '" . mysql_real_escape_string($id) . '"';
 $result= mysql_query($query);

 if (mysql_num_rows($result) > 0) { 
      while($row = mysql_fetch_row($result)) {

         echo $row[1];
               }
         }

else { 
// no 
// print status message 
echo "No rows found!"; 
     }

Front-End Code


 jQuery(document).ready(function(){ 
 jQuery("input.myid").keyup(function(e){ 
 e.preventDefault(); 
 ajax_search(); 
          }); 
     });

 function ajax_search(){
 var search_val=jQuery("input.myid").val(); 
 jQuery.post("find.php", {id : search_val}, function(data){

 jQuery("input.fname").val(data);  

        }   
)}
  • 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-01T01:00:02+00:00Added an answer on June 1, 2026 at 1:00 am

    You can use function json_encode() to convert an array into json format. And convert to array from json using function json_decode().

    you have to just pass one parameter in function that is the array you want to encode or decode.

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

Sidebar

Related Questions

I currently have code which will pull the first element from a database record
We currently have code like this: Dim xDoc = XDocument.Load(myXMLFilePath) The only way we
Using dotnet 2.0. I currently have code like this : DataView dv = new
Is there a better way to do this jquery code? Currently I have to
There is probably is simple fix for this but I currently have code similar
I have some socket connection code that makes use of boost::asio which reads from
In my code, I currently have an exception handling setup which logs exceptions to
i have a problem with my jquery code which is disabling all the text
I have this code: Dim pathString As String = HttpContext.Current.Request.MapPath(Banking.mdb) Dim odbconBanking As New
As a beginner in Ocaml, I have this current working code: ... let ch_in

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.