Results 1 to 12 of 12

Thread: [RESOLVED] help get php table data to datagrid

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    193

    Resolved [RESOLVED] help get php table data to datagrid

    good day,

    I have my site with data in simple html table with rows and columns fetched using php. Now, I need to use vb to get the records from that table to datagridview. This id how I need to do it. I really have no idea how to code this. I hope somebody can help so I can learn this too. TIA

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,348

    Re: help get php table data to datagrid

    If you're suggesting that you want to somehow load the web page in your VB.NET app and get the data from it to then display in a grid then that is a very bad idea if you can possibly do it any other way. If you have no other option, what you are trying to do is generally known as "screen scraping", so you can do some research on that term to find out how to do it in VB.NET. Once you know the principles involved, you can make an attempt and then, if things don't go to plan, you can post back and show us exactly what you did and let us know exactly what happened when you did it.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    193

    Re: help get php table data to datagrid

    the other way of doing that i can do is using mysql driver but i dont want the user, especially those that are not techy to go to that process. i need my app to be simple and standalone for the app is not that sophisticated software.

    im not sure about the word scraping but yes maybe if that is the term.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,348

    Re: help get php table data to datagrid

    Quote Originally Posted by genlight View Post
    the other way of doing that i can do is using mysql driver but i dont want the user, especially those that are not techy to go to that process. i need my app to be simple and standalone for the app is not that sophisticated software.
    I don't understand the issue. The user doesn't have to go to any process. You would write the code to access the database directly or via a web service that delivers the data specifically and then display it. It's no different to the user because it all happens in code either way. The main difference is that the application is more robust if not using screen scraping and the code may well be much simpler.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    193

    Re: help get php table data to datagrid

    no, i mean, the user would be needing to install mysql driver if i do the other way. i will be doing a standalone program just for logging in and vieweing of result. its not a complicated app. this is why i am doing this approach.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,348

    Re: help get php table data to datagrid

    Quote Originally Posted by genlight View Post
    i mean, the user would be needing to install mysql driver if i do the other way.
    No they wouldn't. You can simply deploy the appropriate MySQL DLL(s) with your app.

    That said, a web service would be a better option than accessing an online database directly. The web service could be written in PHP or ASP.NET and then your Windows app can make calls to that without having to know anything about the database.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    193

    Re: help get php table data to datagrid

    yes that is what im saying. i have a webservice running php. with that, i am loading a php page with html table wherein i will be needing to extract it to datagridview for manipulation later on.

    i need help how to extract it to datagridview.
    Last edited by genlight; Dec 11th, 2017 at 10:56 AM.

  8. #8
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,043

    Re: help get php table data to datagrid

    You can do that, but what JMC is saying is that it isn't efficient to use the PHP to load the data into HTML, then pull the data back out of the HTML. It would be far more efficient to load the data into some other structure and offer up just that as a web service. JSON would be the obvious item, with XML also being possible (though it would result in a slightly larger package). It doesn't sounds like you have a HUGE amount of data, either. If the amount of data gets large, then you'd want to arrange the service to return X number of rows, but you make it sound like the amount of data isn't all that big, so you could just put the whole thing into a JSON array.

    Technically, packing it into HTML and stripping it back out would be fairly similar. For example, you could build up a table with a set of rows. The receiver would have to parse the data back out. It's that last step that would get costly, since there's no particularly clean and simple way to do that. With XML, if you set it up right, you could simply call the ReadXML method of a datatable to fill the datatable with the XML, which you could then bind to the DGV for display. JSON is somewhat more popular, and a bit more compact. Getting JSON into a datatable is a bit more complicated than a single method, but not all that much more complicated.

    So, if the reason you are doing the HTML is because that's what you know how to do, I think you should look into a Web Service returning JSON, instead. There should be plenty of examples of that.
    My usual boring signature: Nothing

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,348

    Re: help get php table data to datagrid

    Quote Originally Posted by genlight View Post
    yes that is what im saying. i have a webservice running php.
    But that's not what you said. A web service and a web site are two different things. A web site outputs HTML that is intended to be displayed in a browser application while a web service outputs data that is intended to be consumed in code. Which is it that you actually have? You said that you have an HTML table so it sounds like a web site. I'm saying that an actual web service would be better.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    193

    Re: help get php table data to datagrid

    i see. i will check json but i dunno also how vb get data from json to grid.

  11. #11
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,348

    Re: help get php table data to datagrid

    Quote Originally Posted by genlight View Post
    i dunno also how vb get data from json to grid.
    So do some research to find out. Find what information you can, put it to use and then post back if and when you encounter an issue.

    That said, you should probably break the problem down first. For instance, you can display the contents of a DataTable or some other list in a DataGridView easily by simply binding. That means that if you can populate a DataTable or some other list with data received as JSON then the DataGridView is irrelevant to your issue.

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    193

    Re: help get php table data to datagrid

    I am closing this for now for I need lot of reading to do with this.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width