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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:56:51+00:00 2026-06-15T10:56:51+00:00

Im having a problem with my php/jquery script. The PHP script is suppose to

  • 0

Im having a problem with my php/jquery script. The PHP script is suppose to get an array of fields from a MySQL database, then parse it to JSON and echo it so that i can grab it in my Jquery script.

The problem is that the Jquery script is not grabbing the data correctly, or it is not handling the JSON correctly – or the last possibility that I am doing something wrong (which might be the case because Jquery is a new field of work for me).

I have tried a lot of different Jquery scripts i found on the internet, but here is my current code:

PHP:

<?php 
     include("../../config.php");
     $roomId = $_POST['roomId'];

     $data = mysql_query("SELECT field FROM fields WHERE room = '$roomId' 
        AND value = 1 AND TYPE = ''") or die(mysql_error());

    while ($users = mysql_fetch_array($data)) {
        echo json_encode($users);
    }
?>

The Jquery script:

function UpdateRoom() {
    var data = 'roomId='+roomId;

    $.ajax({
        type: "POST",  
        url: "chatfunctions/getplacementfield.php",
        dataType: 'json',
        data: data,
        success: function(data){
            var arrayValues = $.parseJSON(data);
            $.each(arrayValues, function() {
                $('#f' + parseInt(arrayValues.field).append('<div id="user" />');
             });
        }
    }); 
}

Anyone who can tell me what I am doing wrong. If this is bad Jquery or PHP then tell me what’s wrong as I mentioned earlier I am new to Jquery and not an expert in PHP.

PS: I am not getting any erros in the firebug console

  • 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-15T10:56:53+00:00Added an answer on June 15, 2026 at 10:56 am

    Try this, i hope you will get an idea from this eg. –

    PHP:

    <?php
    
      $con = mysql_connect("localhost","root","");
      $dbs = mysql_select_db("rs", $con);
    
      $result = mysql_query("SELECT * FROM profile") or die(mysql_error()); 
      $json = array(); 
      while ($row = mysql_fetch_assoc($result)) { 
      $json[] = $row;
      }
    
      print json_encode($json);   
      exit;
    
    ?>
    

    Jquery:

    $(function(){
    
        $.getJSON("userinfo.php",function(data)
        {
        $.each(data, function(i,data){
        var jsondata ="<li>Name : "+data.fname+" "+data.lname+"</li>";
        $(jsondata).appendTo("ol#userlist");
            });
            });
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble with a jQuery script.. The script displays posts from Mysql
My PHP script is having a problem decoding the JSON that I'm sending to
I'm having a problem loading a PHP file using .get (even used .load) with
The problem I am having is that my jquery script is not returning the
I have made a jQuery script that loads items from the database when the
I'm having a problem with jQuery(or maybe php). I want forms to be submitted
I am using jquery datatables to display data from a mysql database. When you
Im having diffiuclty getting the Jquery UI to work with php,mysql. below is the
I'm having a problem with php's for loop. The loop iterates too fast and
I'm having a problem with a PHP website running on IIS 7 on Windows

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.