Windows Phone Get Retrieving selected customer Data list from Web Server php/mysql
Hi i want to get selected customer data list from web server. i followed given below code it's working fine for static but dynamically get null reference of customer id.
I am using code given below .
1.php code
Code (PHP)
<?php
$objConnect = mysql_connect("localhost","root","");
$objDB = mysql_select_db("mydatabase");
if (isset($_GET["scustomerID"])) {
$customer_id = $_GET['scustomerID'];
$result = mysql_query("SELECT * FROM pim_productdeal where customer_id= $customer_id") or die(mysql_error());
//$strSQL = "SELECT * FROM pim_productdeal WHERE customer_id = 1 ";
$objQuery = mysql_query($result);
$intNumField = mysql_num_fields($objQuery);
$resultArray = array();
while($obResult = mysql_fetch_array($objQuery))
{
$arrCol = array();
for($i=0;$i<$intNumField;$i++)
{
$arrCol[mysql_field_name($objQuery,$i)] = $obResult[$i];
}
array_push($resultArray,$arrCol);
}
mysql_close($objConnect);
echo json_encode($resultArray);
}
?>
2.C# Code
Code (C#)
if (LoginPage.strcustomer_id_k == null)
{
MessageBox.Show("Please add any product to watchlist");
this.NavigationService.Navigate(new Uri(string.Format("/MainPage.xaml?selectedItem="), UriKind.Relative));
}
else
{
string url = "http://192.168.2.75/Login/getData.php";
Uri uri = new Uri(url);
client = new WebClient();
client.AllowReadStreamBuffering = true;
client.DownloadStringCompleted += client_DownloadStringCompleted;
client.DownloadProgressChanged += client_DownloadProgressChanged;
client.DownloadStringAsync(uri);
//*** SystemTray ProgressBar ***'
prog = new ProgressIndicator();
prog.IsVisible = true;
prog.IsIndeterminate = true;
prog.Text = "Downloading....";
SystemTray.SetProgressIndicator(this, prog);
}
private void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Cancelled == false & e.Error == null)
{
StringBuilder postData = new StringBuilder();
postData.AppendFormat("{0}={1}", "scustomerID", HttpUtility.UrlEncode(LoginPage.strcustomer_id_k));
Member.customer_id = LoginPage.strcustomer_id_k;
Member deserializedMember = new Member();
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(e.Result));
ObservableCollection<Member> list = new ObservableCollection<Member>();
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ObservableCollection<Member>));
list = (ObservableCollection<Member>)serializer.ReadObject(ms);
List<Member> myCustomer = new List<Member>();
foreach (Member cm in list)
{
string scustomerID = cm.customer_id.ToString();
string sproductID = cm.product_id.ToString();
string sproduct_name = cm.product_name.ToString();
string sproduct_image = cm.product_image.ToString();
string starget_price = cm.target_price.ToString();
string sretailer = cm.retailer.ToString();
string speriod = cm.period.ToString();
string smobile = cm.mobile.ToString();
myCustomer.Add(new Member(scustomerID, sproductID, sproduct_name, sproduct_image, starget_price, sretailer, speriod, smobile));
}
this.CustomerList.ItemsSource = myCustomer;
prog.IsVisible = false;
}
}
Tag : Mobile, MySQL, WebService, C#, Windows Phone, Windows
Date :
2013-07-27 11:57:47
By :
Windows Phone
View :
1039
Reply :
1
Windows Phone Search Data from Web Server
Date :
2013-07-27 19:48:35
By :
mr.win
Load balance : Server 04