Jump to content

Use Array or Database? Which way to go from here


MikeDizzle

Recommended Posts

I have some code that uses simpleXML to parse the contents of a google base xml file. Currently i have it looping thru and echo'ing the desired information. I want to be able to have more control of the data allowing me to sort, filter, and maybe even graph the output.

Would it be better to use a MySQL database to store the results or should I use an array? I'm not very comfortable with multideminsional arrays even after reading several tutorials.

Here is the code snippet:

[color=blue]$xml = simplexml_load_file($file) or die ("Unable to load XML file!");

// build the table and display results by looping thru each element
echo "<table>";
foreach ($xml->entry As $entry)
{
// set the namespace for g:children using http://base.google.com/ms/1.0
$ns_g = $entry->children('http://base.google.com/ns/1.0');
// output the desired content

echo "<tr>";
echo "<td>";
echo $ns_g->year . " ";
echo "</td>";
echo "<td>";
echo $ns_g->make . " ";
echo "</td>";
echo "<td>";
echo $ns_g->model . " ";
echo "</td>";
echo "<td>";
echo $ns_g->trim . " ";
echo "</td>";
echo "<td>";
echo $ns_g->mileage . " ";
echo "</td>";
echo "<td>";
echo $ns_g->price;
echo "<br />";
echo "</td>";
echo "</tr>";

}[/color]

Thanks for any advice/instruction you can provide me  :)
[quote author=dgiberson link=topic=122838.msg507087#msg507087 date=1169058375]
I guess it all depends how far down the line you want to access this information... if it's a one time thing go with an array, otherwise setup a table to store the information.
[/quote]

It will be a one time thing, becuase the xml file being parsed will be different every time. The information would only be used short term, basicly session length.

given the code above, how would you recommend replacing the current echo output with saving the data to an array?

Thank you again

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.