help with my block design

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phase
Forum Newbie
Posts: 24
Joined: Sun Jul 18, 2004 10:47 am

help with my block design

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

please post an export of the table structure and data stored in this table.
rdionne1187
Forum Newbie
Posts: 17
Joined: Tue Feb 01, 2005 9:30 am
Location: CT

Post 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
phase
Forum Newbie
Posts: 24
Joined: Sun Jul 18, 2004 10:47 am

Post 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]
Post Reply