PHP coding problems

monoVertex

I'm back!
Reaction score
460
Any idea what's wrong with this? My page is blank...

PHP:
<?
$name=array(
array("Abstract Fantasy","Abstract Tech","Computer Flames","Contaminated","Electricity","Red Planet","Angel","Devilish","Demoness","Toxic"),
array("Goth's High #1","Goth's High #2","Goth's High #3","Goth's High #4","Goth's High #5","Topaz-Games #1","Topaz-Games #2","Grigore Moisil Tulcea","Arcane Corruption","Apostle Wings","War Anvil #1","Gamerz-Forum","War Anvil #2"),
array("Grozzy","Mu Vaslui","S9 #1","Shemorays","Smith","Mamako","Pandaren Campaign","Apostle O","Daikenkaiking","S9 #2","Fantasy","Hulk","Wolverine","Santa Demon","The Future","Evil Dragon","Vengeance","Demons"),
array("Freedom","Smith #1","Smith #2"),
array("Utator #1","Utator #2","Utator #3"),
array("Decorative #1","Decorative #2","Decorative #3"),
array("The Lost One","The High One","Uenvar","Skirrmeth","Tephnaemar Mage","Arch-Templar","Assassin","Shemorays Templar"),
array("Water Sword","Ice Sword","Sky Sword","Angelic Sword","Fire Sword","Nightmare Sword","Malevolent Sword","Demonic Sword"),
array("Warrior","Mage","The Chosen","Monster","Devil's Acolyte","The Devil"),
array("Night Elf","Dragonx","Specter","Phyrow","Megalodon","Swamp Monster","Guardian","Angry Dragon","Death Revenant","Archon Army","Archon","Future City","Gun","World Map","Hell Fiend","Elite Soldier"));


$category=array("others","banners","signatures","grafitties","utators","decorative","templars","swords","worms","others");

$max_set=10;
$min_set=0;

$max[0]=10;
$max[1]=13;
$max[2]=18;
$max[3]=3;
$max[4]=3;
$max[5]=3;
$max[6]=8;
$max[7]=8;
$max[8]=6;
$max[9]=16;
$max[10]=14;

for($tab=0;$tab<=5;$tab++){
echo '<div id="subtab">';
echo '<a name="'.$category[$tab].'"><h1 class="question">'.$category[$tab].'</h1></a><br />';
echo '<center>';

for($table=1;$table<=$max[$tab];$table++){
echo '<table border="0" cellspacing="15"><tr>';
if ($table%5==0){
echo '</tr></table><br /><br />';
echo '<table border="0" cellspacing="15"><tr>';}

echo '<td valign="top"><div id="thumb"><a href="gallery.php?set='.$tab.'&image='.$table.'"><img src="Thumbnails/'.$tab.'_'.$table.'" alt="'.name[$tab[$table]].'" border="0"/></a></td></div>';}}
?>
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,494
At least one table is never closed.
The last line says "</td></div>" instead of "</div></td>".

Anyway, it is, generally, an error to try to coerce your code into following your data.
Instead, reorganize the data...

PHP:
<?php
$AllData = array(
	"others"		=> array(
		"gallery" => 0,
		"content" => array("Abstract Fantasy","Abstract Tech","Computer Flames","Contaminated","Electricity","Red Planet","Angel","Devilish","Demoness","Toxic")
		),
	"banners"		=> array(
		"gallery" => 1,
		"content" => array("Goth's High #1","Goth's High #2","Goth's High #3","Goth's High #4","Goth's High #5","Topaz-Games #1","Topaz-Games #2","Grigore Moisil Tulcea","Arcane Corruption","Apostle Wings","War Anvil #1","Gamerz-Forum","War Anvil #2")
		),
	"signatures"	=> array(
		"gallery" => 2,
		"content" => array("Grozzy","Mu Vaslui","S9 #1","Shemorays","Smith","Mamako","Pandaren Campaign","Apostle O","Daikenkaiking","S9 #2","Fantasy","Hulk","Wolverine","Santa Demon","The Future","Evil Dragon","Vengeance","Demons"),
		),
	"grafitties"	=> array(
		"gallery" => 3,
		"content" => array("Freedom","Smith #1","Smith #2"),
		),
	"utators"		=> array(
		"gallery" => 4,
		"content" => array("Utator #1","Utator #2","Utator #3"),
		),
	"decorative"	=> array(
		"gallery" => 5,
		"content" => array("Decorative #1","Decorative #2","Decorative #3"),
		),
	"templars"		=> array(
		"gallery" => 6,
		"content" => array("The Lost One","The High One","Uenvar","Skirrmeth","Tephnaemar Mage","Arch-Templar","Assassin","Shemorays Templar"),
		),
	"swords"		=> array(
		"gallery" => 7,
		"content" => array("Water Sword","Ice Sword","Sky Sword","Angelic Sword","Fire Sword","Nightmare Sword","Malevolent Sword","Demonic Sword"),
		),
	"worms"			=> array(
		"gallery" => 8,
		"content" => array("Warrior","Mage","The Chosen","Monster","Devil's Acolyte","The Devil"),
		),
	"others"		=> array(
		"gallery" => 9,
		"content" => array("Night Elf","Dragonx","Specter","Phyrow","Megalodon","Swamp Monster","Guardian","Angry Dragon","Death Revenant","Archon Army","Archon","Future City","Gun","World Map","Hell Fiend","Elite Soldier")
		),
	);
?>

Looks slightly more readable already.
At the very least, it follows somewhat the intended layout.

PHP:
<?php
foreach($AllData as $category => $data)
{
	echo '<dl>';
	echo '<dt>'.ucfirst($category).'</dt>';
	for($i = 1; $i < count($data["content"]); $i++)
	{
		echo '<dd>Gallery '.$data["gallery"].', link value '.$i.': '.$data["content"][$i].'</dd>';
	}
	echo '</dl>';
}
?>

For every category show the content of its gallery.


Well, for inspiration or so... :p
 

DDRtists

ɹoʇɐɹǝpoɯ ɹǝdns
Reaction score
415
I've been asked to translate your post, Ace. :p

Lets break it down a bit:
PHP:
<?
	"worms"		=> array(
		"gallery" => 8,
		"content" => array("Warrior","Mage","The Chosen","Monster","Devil's Acolyte","The Devil"),
		),
	);
?>

It's a cleaner way to say what you did, with it being more readable.
What it's saying:
The Variable "Worms" is the 8th "gallery", and it contains these things:
"Warrior","Mage","The Chosen","Monster","Devil's Acolyte","The Devil"

Then, this script here:
PHP:
<?php
foreach($AllData as $category => $data)
{
	echo '<dl>';
	echo '<dt>'.ucfirst($category).'</dt>';
	for($i = 1; $i < count($data["content"]); $i++)
	{
		echo '<dd>Gallery '.$data["gallery"].', link value '.$i.': '.$data["content"][$i].'</dd>';
	}
	echo '</dl>';
}
?>
Will go though each categories content, and make a entry on your page for it.

Sorry if I'm not laying it out enough, I just woke up. :p
 

monoVertex

I'm back!
Reaction score
460
Well, it's not really how I want it... and Ace's script is a bit too... advanced for me :p. I got the variables part, but, in the script for showing up the stuff, I have no idea what <dl> and <dd> mean :D. Sorry for my noobiness. If you are willing to help me further, thank you!
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,494
> I have no idea what <dl> and <dd> mean

Well, copy & paste the two scripts to a new page, and have a look...

dl = definition list
dt = definition title
dd = definition definition

Gives a basic "header + list" view.


Something like this:

Title 1
- this
- that
- other

Title 2
- here
- we
- go


> Well, it's not really how I want it...

Agreed.

Then again, I already had to majorly guess what your script was supposed to do... let alone get the planned layout...



Either way, what's the problem?
And what you mean with "advanced"?

> For every category show the content of its gallery.

Actually, that was the part where I guessed your plan.
The rest followed from following (sic) that assumption :p
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
<dl> is just another html tag that you should use. I have no idea why ace used a dl there but anyway.

w3school said:
A definition list is not a list of items. This is a list of terms and explanation of the terms.

A definition list starts with the <dl> tag. Each definition-list term starts with the <dt> tag. Each definition-list definition starts with the <dd> tag.
http://www.w3schools.com/html/html_lists.asp
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,494
> I have no idea why ace used a dl there

To keep it simple.

Some weird echo full of td tr and other table stuff is not going to help...

Layout is something you can always add later.
Or just style it according to plan.

However, that's something you worry about once you got some actual structure.
Not before.
 

monoVertex

I'm back!
Reaction score
460
Ok, my script is supposed to give something like this (sorry for the long loading time). But, this is done with brute HTML :D. And it takes me too much too update it... I tried to remake the same effect, but using PHP. And the page is blank :D.

I'll try to mess up with what you gave me, Ace and see what I get :D.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top