...

View Full Version : Generating XML document via PHP and MySQL Database



CComley
07-03-2012, 04:43 PM
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!

Keleth
07-03-2012, 04:47 PM
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?

CComley
07-03-2012, 04:51 PM
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.

Keleth
07-03-2012, 05:07 PM
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.

CComley
07-03-2012, 05:23 PM
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 :)

Keleth
07-03-2012, 05:35 PM
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.

DrDOS
07-04-2012, 05:32 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum