Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Generating XML document via PHP and MySQL Database

    Hello everyone.

    Before I start, let me say that I'm very limited in my knowledge of PHP and other types of coding (except for HTML, I'm pretty good at that, but it's horribly outdated)

    I help run a dining guide website for my company. We're trying to make a mobile version of this website which will update automatically when we change the database.

    Here's what I need to do, I have a database that has almost 300 restaurants. Each one of those restaurants has 43 fields, (things like hours, address, food type, phone number, price, etc. etc. etc). One of they key fields is "status". When "status" is set to "1" in the database, the restaurant shows up on the website. If "status" is set to "0", the restaurant is hidden from the user.

    I've read multiple tutorials on how to generate an XML document via PHP, but I did not see anything anywhere that basically says "Only put the restaurants where "status" = "1" into the XML document".

    Also, out of those 43 fields, I only need to use roughly 30 or so of them for the mobile site. How do I use PHP to only select some of them and not every row in the database?

    Thanks!

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,536
    Thanks
    45
    Thanked 259 Times in 256 Posts
    You use MySQL to return only the elements you want. Do you have any code yet? Have you read up on the basics of MySQL?

  • #3
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Keleth View Post
    You use MySQL to return only the elements you want. Do you have any code yet? Have you read up on the basics of MySQL?
    No I haven't read anything on MySQL.

    To be honest, I'm not really to sure what it is.

    I thought it was just a type of database where you just store information. Is it a type of coding?

    There is already a bunch of coding, but it's not working. We had our old web developer working on a mobile version of the site, but then he got a different job and left with it unfinished.

  • #4
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,536
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Well, it is a database, but to interface with it, you have to write code the MySQL understands (referred to as "commands"). These are typically wrapped in the mysql_query function (look for it in your tutorials).

    It sounds like you need a developer... unless you're willing to get the basic grasp of things, this forum is mostly about guiding people and teaching, not simply writing code for people. There is a section of this forum where you can hire developers.

    If you already have code written that generates the XML, we can certainly help you figure it out, though the typical format of the query will be something like SELECT * FROM table WHERE status = 1. This will return only the values in "table" (replace table with the name of your table) where status = 1. Again, look for mysql_query in your tutorials.

  • #5
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Keleth View Post
    Well, it is a database, but to interface with it, you have to write code the MySQL understands (referred to as "commands"). These are typically wrapped in the mysql_query function (look for it in your tutorials).

    It sounds like you need a developer... unless you're willing to get the basic grasp of things, this forum is mostly about guiding people and teaching, not simply writing code for people. There is a section of this forum where you can hire developers.

    If you already have code written that generates the XML, we can certainly help you figure it out, though the typical format of the query will be something like SELECT * FROM table WHERE status = 1. This will return only the values in "table" (replace table with the name of your table) where status = 1. Again, look for mysql_query in your tutorials.
    Yeah, sadly the hiring of the developer is out of the question. It actually appears as if most of it is coded in javascript, that was generated from somewhere else.

    Eh. Now this thing has be totally confused.

    Thanks for responding

  • #6
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,536
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Well, some stuff can be done in Javascript, but you can't pull stuff from a database with Javascript. Javascript can make things look pretty on the front end, do stuff visually, but it can't do the core meaty stuff... its only at the users end.

    Like I said, take a look at some of those PHP to XML tutorials you mentioned, and look for the SQL commands... and if you have code from your previous developer, post it here and we can try to help.

  • #7
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,976
    Thanks
    15
    Thanked 229 Times in 229 Posts
    XML should be really easy to write with PhP. I'm making .svg graphics with PhP, which is a kind of XML document, but more complicated than the usual XML document, and it works really well. For instance you can make a graph to your own specifications and save it as a .png file.


  •  

    Posting Permissions

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