Click here to Skip to main content
15,891,946 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i dont know to to get the information from this php script and insert into listviwe intem




PHP
<?php
include 'conf.php';
    $result = mysql_query("SELECT * FROM sales");
    while($row = mysql_fetch_array($result)){
                echo  $row['s_number'] ;
                echo  $row['product_name'];
                echo  $row['goods_number'];
                echo  $row['sold_date'] ;
                echo  $row['time_sold'];
                echo  $row['customer_name'];
                echo  $row['customer_addr'] ;
                echo  $row['moved_status'];
                echo  $row['report'];
                echo  $row['update_note'] ;
                }
?>
Posted
Updated 30-Sep-20 1:13am
Comments
enhzflep 26-Feb-15 3:17am    
You 'download' the php script. I.e, you download the contents of the file at (say) "localhost/nameOfPhpScript.php" - instead of getting back the php's source code, you get back the output of running the php.

If there's some JSON parsing stuff for VB.NET (which, I'd be amazed if there weren't) it would be easier to return a JSON encoded array. You can then parse this in your program to get an easy to traverse array, rather than having to parse the text output of the script yourself.
Michael_Davies 1-Mar-15 16:29pm    
What have you tried on the VB .Net side? Have you looked at using WebRequest?

Hope you are using HTTPS. It is bad practice to just have a script execute server side that returns data without some kind of verification, anyone gets the name of the script get the data...
Wolfsoftonline 2-Mar-15 19:16pm    
i will take care of that later
Michael_Davies 5-Mar-15 15:50pm    
okay, here is a modified sample of code I use, the PHP side I'll let you work out but you will need JSON.

On execution the variable responseFromServer will contain the response in whatever form the PHP returns it, again I recommend JSON to code the response.

Dim responseFromServer As String
Dim myRequester As WebRequest
Dim myRequestPayload As Dictionary(Of String, String)

myRequestPayload = New Dictionary(Of String, String)
myRequestPayload.Add("key", HashKey) ' Add a "key" variable the value of which is verified by the PHP script
myRequestPayload.Add("Customer", 1) ' Add a customer id for the PHP to use in the SQL request.

Dim postData As String = "payload=" + Uri.EscapeUriString(JsonConvert.SerializeObject(myRequestPayload)).Replace("&", "%26").Replace(";", "%3B")
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)

myRequester = WebRequest.Create(<site link="">)
myRequester.Method = "POST"
myRequester.ContentType = "application/x-www-form-urlencoded"
myRequester.ContentLength = byteArray.Length

Dim dataStream As Stream = myRequester.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()

Try
response = CType(myRequester.GetResponse(), HttpWebResponse)
Catch ex As Exception
Response = CType(ex, System.Net.WebException).Response
End Try

If Response.StatusCode = HttpStatusCode.OK Then
Dim reader As New StreamReader(Response.GetResponseStream())

responseFromServer = reader.ReadToEnd()

reader.Close()

...
Wolfsoftonline 6-Mar-15 9:16am    
thanks very much that lovely i had no idea about json

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900