PHP: update* : get source code from a file

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   PHP: update* : get source code from a file
Gareth
CZ Addict
 Codezwiz Site Donator
Gareth has been a member for over 20 year's 20 Year Member
uk.gif
Occupation: Student, Webmaster
Gender: Male
Fav. Sports Team: Liverpool FC
Status: Offline
Joined: May 29, 2004
0.08 posts per day
Posts: 587
Points: 38,220
   
This is what im trying to do:

Im trying to make it so that $blocks is:


$query = "SELECT * FROM blocks order by number ASC";
    $result = mysql_query($query);
    while($r=mysql_fetch_array($result))   
    {
    $blocktitle = $row[title];
    $blockfile = $row[file];
    $blockfile2 = @file("blocks/".$blockfile."");
    if (!$blockfile2) {
   $blockcontent = "Block Error";
    } else {
   include("blocks/".$blockfile."");
    }
    include("templates/$template/block.php");
}


what im trying to do is get blocks on the left side of my site, ordered by the number out of the sql, example: number 1 up top, 2 next 3 then etc...
If anyone knows another way to code it and do the same thing your welcome to tell me icon_mrgreen.gif

Inside block.php (in my template folder) there is the html for the block and $blocktitle and $blockcontent if that helps

Thanks For Any Help.

Gareth



_________________
[ Register or login to view links on this board.]
Back to top Reply with quote
#2   re: PHP: sql query in varibale
Gareth
CZ Addict
 Codezwiz Site Donator
Gareth has been a member for over 20 year's 20 Year Member
uk.gif
Occupation: Student, Webmaster
Gender: Male
Fav. Sports Team: Liverpool FC
Status: Offline
Joined: May 29, 2004
0.08 posts per day
Posts: 587
Points: 38,220
   
OK Fixed That Problem, All I Need To Do Now Is Make $blocks Be blocks();

So its the function
I've tried:
$blocks = blocks();


But that didn't work.
Im not 100% sure this can be done, But any help is appreciated.

Thanks
Gareth



_________________
[ Register or login to view links on this board.]
Back to top Reply with quote
#3   re: PHP: update* : get source code from a file
Gareth
CZ Addict
 Codezwiz Site Donator
Gareth has been a member for over 20 year's 20 Year Member
uk.gif
Occupation: Student, Webmaster
Gender: Male
Fav. Sports Team: Liverpool FC
Status: Offline
Joined: May 29, 2004
0.08 posts per day
Posts: 587
Points: 38,220
   
LMAO, sorted that out, but bumpted into another something else:

How do i make $blockcontent equal a file, e.g. $blockcontent = blocks/testblock.php ?

I've tried all sorts i've found on google, but none successfull

If anyone could find me something else or keep lookin for me (i died of boredom searching) that would be much appreciated as it all goes towards my portal im making, And codezwiz is definately gona have a credit link icon_razz.gif

Thanks

Gareth




_________________
[ Register or login to view links on this board.]
Back to top Reply with quote
#4   re: PHP: update* : get source code from a file
Gareth
CZ Addict
 Codezwiz Site Donator
Gareth has been a member for over 20 year's 20 Year Member
uk.gif
Occupation: Student, Webmaster
Gender: Male
Fav. Sports Team: Liverpool FC
Status: Offline
Joined: May 29, 2004
0.08 posts per day
Posts: 587
Points: 38,220
   
All this for nothing, sorry guys, you might aswell delete this, or not, for anyone that wants to know how to parse a file to a variable use this:

ob_start();        //start output buffering
include ("contentfile.php");    //all output goes to buffer
$buf = ob_get_contents();    //assign buffer to a variable
ob_end_clean();        //clear buffer and turn off output buffering


and place $buf were you want it to appear icon_razz.gif
dont argue that you can use include or require cause sometimes you cant icon_mrgreen.gif

Gareth



_________________
[ Register or login to view links on this board.]
Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum