me1000 Posted March 14, 2006 Share Posted March 14, 2006 Ok ive got my database driven web site Im using [code] $query = "SELECT * FROM $sTableName WHERE ID=$inPageID LIMIT 1"; $_CONTENT = mysql_fetch_array(mysql_query($query));<?= $_CONTENT['PAGE_CONTENT'] ?>[/code]to insert the content, into the page.Now if I wanted to add a php command into the page (the part thats stored on the database) im not sure what to do.can someone help me out here?Thanks, Quote Link to comment Share on other sites More sharing options...
keeB Posted March 14, 2006 Share Posted March 14, 2006 I am not sure quite what you're asking.. Quote Link to comment Share on other sites More sharing options...
me1000 Posted March 14, 2006 Author Share Posted March 14, 2006 ok say you wanted to do an include[code]<?include("somepage.php");?>[/code]well if a add that code to the page, then it comes out as nothing at all.but if you get rid of the <? ?> tags then it comes out include("somepage.php"); on the page.its the same way with every command. Quote Link to comment Share on other sites More sharing options...
kamiza Posted March 14, 2006 Share Posted March 14, 2006 No no, he wants to retrieve something from a mysql database, and then display itright now all you need to do is<? echo "$_CONTENT"; ?>and actually just use $Content, dont need underscore--but if want like organized do something like this[code]<?$query = "SELECT * FROM tablename ORDER BY id";$result = mysql_query($query); // Same as you have but don't do the fetch_array yetwhile($c = mysql_fetch_array($result)){echo "$c[username] <br>";echo "$c[message] <br>";echo "$c[date] <br>";?>[/code] Quote Link to comment Share on other sites More sharing options...
me1000 Posted March 14, 2006 Author Share Posted March 14, 2006 no the page works fine, with standard HTML. the site is already up a running off of a mysql database. I just gave you some sample code. im using the _ for easier viewing (by myself).im trying to display a page from the database which works fine with standard HTML. but If I want to add php to the page (the page being stored in the database) it comes out with wierd results (as shown below) Quote Link to comment Share on other sites More sharing options...
keeB Posted March 14, 2006 Share Posted March 14, 2006 [!--quoteo(post=355084:date=Mar 14 2006, 10:02 PM:name=me1000)--][div class=\'quotetop\']QUOTE(me1000 @ Mar 14 2006, 10:02 PM) [snapback]355084[/snapback][/div][div class=\'quotemain\'][!--quotec--]no the page works fine, with standard HTML. the site is already up a running off of a mysql database. I just gave you some sample code. im using the _ for easier viewing (by myself).im trying to display a page from the database which works fine with standard HTML. but If I want to add php to the page (the page being stored in the database) it comes out with wierd results (as shown below)[/quote]So inside of your database cell you have PHP code that you want to be interpreted?I've never done that before, nor can I see any reason why you would want to.. Would you like to explain what exactly you're trying to accomplish? Quote Link to comment Share on other sites More sharing options...
me1000 Posted March 14, 2006 Author Share Posted March 14, 2006 Exactly!well there are a few things I would like to do,but I wiould like to make a random page generator. this would need to be php driven because it would need to grab a random page from the database. and since im am added pages all the time, I dont want to add a line to a JS every time I add a page. there are several random things I would like to do. ive bee trying to see how the server would inturprate it and send it to the browser.and tyhis is what ive come up with.[code]<?= <?echo = "Hello world"; ?>?>[/code]with this I can see that there are extra php tags (<? ?>) (when I test this out it shows nothing at all)so i try this.[code]<?= echo = "Hello world"; ?>[/code]This shows "echo = "Hellow world";" on the page its not inturpreted as saying "hello world".I hope someone is able to help me. Quote Link to comment Share on other sites More sharing options...
keeB Posted March 15, 2006 Share Posted March 15, 2006 the problem is.. to 'output' the results.. you're PRINT or ECHO'ing them..which.. of course, you're just printing a string and it's not interpreted..if you want to pull a random page from the db, there's much easier ways..Make the pages in .php format.. and generate a random number between 1 and SELECT COUNT(*) from TABLENAME .. the tableName will contain the FILENAME of a local .PHP file.. which in your GENERATERANDOMPAGE.php.. it will include($randomFileName); from the DB. :)If you need help implimenting that, just ask [= Quote Link to comment Share on other sites More sharing options...
me1000 Posted March 16, 2006 Author Share Posted March 16, 2006 well i know its posible to execute a php function it. is there a way i can recode the page content output to make this posible?as I realy need to be able to do this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.