(O/T) Some funky php coding I just did...

For bug reports and fixes, installation issues, and new ideas for technical features.

Moderator: SEOW Developers

Post Reply
No457_Squog
Posts: 28
Joined: Wed 11 Jul 2007 6:28 am
Location: Melbourne, Australia
Contact:

(O/T) Some funky php coding I just did...

Post by No457_Squog »

Hi guys,

This is completely off-topic, but I thought you might perhaps appreciate/belittle a tiny bit of coding that I did for the No457 website:

Code: Select all

	foreach(array ("access" => null,"actions" => null,"badges" => null,"ranks" => null) as $key => $table) {
		$query = mysql_query ( "SELECT * FROM `". $key ."`" );
		while($results = mysql_fetch_assoc ( $query )) {
			$static[$key][] = $results;
		}
	}
	unset($table);
And the usage:

Code: Select all

echo $static['badges'][4]['long'];
Basically - it a whole heap of 'static' tables in MySQL pumped into one big multidimensional array. I've got to make a few different tweaks to it to get it 100% right, but the basics work just fine :)

What do you guys think?
Image
IV/JG7_4Shades
Posts: 2203
Joined: Mon 08 Jan 2007 11:10 pm
Location: Perth, Western Australia

Post by IV/JG7_4Shades »

Looks like it works. In the olden days, the big problem was to take the PHP data and insert that into Javascript to build dynamic web pages. The easiest way of doing this was to use string transfers. So for the MP I serialized all the SQL recordsets into delimited strings and passed them direct to the Javascript for deserialization (using split). Dumb and clunky, but works well.

But then Ajax came along ....
IV/JG7_4Shades
SEOW Developer

Image
Post Reply