Jump to content

Recommended Posts

I am using below mentioned ajax technique to get the value of "member master" if user input any new memberid.. and its successfully working..

 

but only one field value i can get back.. how can i get back value of other fields in table like address phone emails etc..

 

 

 

//memberadd.php

 

function getHTTPObject(){

  if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");

  else if (window.XMLHttpRequest) return new XMLHttpRequest();

  else {

      alert("Your browser does not support AJAX.");

      return null;

  }

 

 

// Change the value of the outputText field

function setOutput(){

    if(httpObject.readyState == 4){

        document.getElementById('txtmemname').value = httpObject.responseText;

       

    }

 

}

                                                 

function doWork(){   

    httpObject = getHTTPObject();

    if (httpObject != null) {

        httpObject.open("GET", "getmember.php?txtmemid="

                        +document.getElementById('txtmemid').value, true);

        httpObject.send(null);

        httpObject.onreadystatechange = setOutput;

    }

}

 

var httpObject = null;

 

 

 

 

 

 

 

 

 

 

 

 

 

//getmember.php

<?php

 

if (isset($_GET['txtmemid']))

$memid=($_GET['txtmemid']);

 

 

 

$link = mysql_connect("localhost", "root", "redhat")

or die("Could not connect : " . mysql_error());

 

$Db = "libmanage";

$Tb = "mem_master";

 

mysql_select_db($Db, $link);

                           

$query = "select mem_name from mem_master where mem_id=$memid";

 

$result= mysql_query($query,$link) or die("");

 

 

$fel=mysql_num_fields($result);

$nro=mysql_num_rows($result);

 

if($nro>0)

{

  $row=mysql_fetch_array($result);

  $memname=$row['mem_name'];

 

 

$_GET['txtmemid']=$memname;

 

echo ($_GET['txtmemid']);

 

}

 

else

{

         

    $_GET['txtmemid']="";

    echo ($_GET['txtmemid']);

   

}

 

exit();

 

mysql_close($link);

Link to comment
https://forums.phpfreaks.com/topic/186081-php-ajax-mysql/
Share on other sites

Dear Maq

 

I am not talking about the sql statment... AS you  can see in the last line in getmember.php there is a variable 'txtbalance'.. I want to  get back the value of that one seperatly as its come along with membername.

 

 

Add the columns to your SELECT statement.

 

All of this other code is unnecessary if you're just trying to extract more data from the database.

Link to comment
https://forums.phpfreaks.com/topic/186081-php-ajax-mysql/#findComment-982674
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.