Jump to content

**solved** Dynamic Table Help


beamerrox

Recommended Posts

[code]CREATE TABLE `map` (
  `id` int(255) NOT NULL,
  `name` varchar(50) NOT NULL default '',
  `size` int(25) NOT NULL default '0',
  `creator` varchar(100) NOT NULL default '',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2;

INSERT INTO `map` (`id`, `name`, `size`, `creator`) VALUES (1, 'Test Galaxy', 25, 'Beamerrox (Site Owner)');[/code]

[code]CREATE TABLE `systems` (
  `id` int(255) NOT NULL,
  `map_id` int(255) NOT NULL default '0',
  `local` varchar(255) NOT NULL default '',
  `family` int(100) NOT NULL default '0',
  `name` varchar(10) NOT NULL default '',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM AUTO_INCREMENT=5;

INSERT INTO `systems` (`id`, `map_id`, `local`, `family`, `name`) VALUES (1, 1, '1, 1', 1, 'Family 1');
INSERT INTO `systems` (`id`, `map_id`, `local`, `family`, `name`) VALUES (2, 1, '25, 1', 2, 'Family 2');
INSERT INTO `systems` (`id`, `map_id`, `local`, `family`, `name`) VALUES (3, 1, '1, 25', 3, 'Family 3');
INSERT INTO `systems` (`id`, `map_id`, `local`, `family`, `name`) VALUES (4, 1, '25, 25', 4, 'Family 4');[/code]


[code]<?
$db = mysql_connect("", "", "");
mysql_select_db("", $db);
?>
<table border="1" cellpadding="2" cellspacing="0">
<?
$map = mysql_fetch_assoc(mysql_query("SELECT * FROM map WHERE id={$_GET['id']}"));
$i = 1;
for($i; $i <= $map['size']; $i++){
?>
<tr>
<?
$j = 1;
for($j; $j <= $map['size']; $j++){
$local = "$i, $j"
$res = mysql_query("SELECT * FROM systems WHERE local='$local'");
?>
<td><? if($res){ echo "1"; } else { echo "0"; } ?></td>
<?
}
?>
</tr>
<?
}
?>
</table>[/code]

i want this page so that it doesn't post all the cells with a 1 in each, the way it is set up is so it only posts the 4 systems to the map that is 25x25, so there should be 4 ones and 421 zeros, i don't know how to make this work

[EDIT]
fixed part of the coding, still have the same problem though
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.