Page 1 of 1

help with my block design

Posted: Thu Mar 03, 2005 2:39 am
by phase
hi, i am trying to get some blocks on the left hand side of my site, basically i want to be able to add a link in the sql which the db reads and then includes that file

Code: Select all

$result = mysql_query("SELECT * FROM blocks WHERE block_side=1 ORDER BY block_priority");
while ($myrow = mysql_fetch_array($result)) {
include $myrowї"block_file"];
}
echo "</table>";
what is happening is that it only shows the 1st result in database which is inblock side=1. the loop doesnt work.
ive tried loads of ways to do this and im at a loss, if someone can help me it would be greatly appreciated.

the structure is like this...
my main page incudes the blocks.php page, the blocks page consists of the above code and opens the link to the block.

thank you

phase

Posted: Thu Mar 03, 2005 7:52 am
by feyd
please post an export of the table structure and data stored in this table.

Posted: Thu Mar 03, 2005 9:20 am
by rdionne1187
what is the included variable, is it more code or is it supposed to be your block, and if so shouldn't you use foreach or such

Posted: Thu Mar 03, 2005 9:43 am
by phase
hey, thanks for the replies, my sql structure is...

Code: Select all

-- 
-- Table structure for table `blocks`
-- 

CREATE TABLE `blocks` (
  `block_id` int(4) NOT NULL auto_increment,
  `block_title` varchar(100) NOT NULL default '',
  `block_file` varchar(100) NOT NULL default '',
  `block_side` int(1) NOT NULL default '0',
  `block_priority` int(2) NOT NULL default '0',
  UNIQUE KEY `block_priortiy` (`block_priority`),
  KEY `block_id` (`block_id`)
) TYPE=MyISAM AUTO_INCREMENT=3 ;

-- 
-- Dumping data for table `blocks`
-- 

INSERT INTO `blocks` VALUES (1, 'Navigation', 'blocks/nav.php', 1, 1);
INSERT INTO `blocks` VALUES (2, 'test block', 'blocks/test.php', 1, 2);

i know ive done something obviosuly wrong but my head cant work out what, ive never tried to include files in db results like this.

thanks again

phase


feyd | help us help you, use

Code: Select all

[/color]