January 25th, 2012, 05:15 AM
|
#1 (permalink)
|
|
Junior Member
Join Date: Dec 2011
Location: chennai
Posts: 61
Device(s):
Thanks: 1
Thanked 0 Times in 0 Posts
|
fetching some data from database using json webservices
Hi Good Evening,
am developed one app..here am using json webservices for fetching data from database...Here am used dis coding part:
<?php
$r=mysql_connect("localhost","root","");
mysql_select_db("xcart",$r);
$q=mysql_query("SELECT * FROM xcart_orders WHERE orderid >'".$_REQUEST['orderid']."'");
while($e=mysql_fetch_assoc($q))
{
$output[]=$e;
}
print(json_encode($output));
mysql_close();
?>
its successfully worked...but all datails displayed..because am used array.
but i dono how is fetching some datas only...here am used dis coding:
<?php
$r=mysql_connect("localhost","root","");
mysql_select_db("xcart",$r);
$q=mysql_query("SELECT * FROM xcart_customers WHERE usertype='C'") or die(mysql_error());
// get the first (and hopefully only) entry from the result
$row = mysql_fetch_array( $q );
// Print out the contents of each row into a table
print(json_encode($row['firstname']." - ".$row['lastname']));
mysql_close();
?>
dis is successfully worked in localhost..then am connecting my coding means its displayederror in logcat..the error is json array exception not converted to json array ..how it is diplayed..i konw my coding part having error..so ly it is displayed..so give me some solutions...thank in advance...
|
|
|