CyDrive Posted February 4, 2007 Share Posted February 4, 2007 Hello, I am trying to make a code box function like the one in phpbb forums. Something like this. And my code goes here. Though I'm not sure how to do this if someone could explain or show me where i could get the source. Thank you in advanced. Quote Link to comment Share on other sites More sharing options...
papaface Posted February 4, 2007 Share Posted February 4, 2007 Pretty simple. Ill start you off. You could do something like this: <?php function codedefine($content) {?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td bgcolor="#666666"><?= $content; ?></td> </tr> </table> <?php } $text = "hello"; echo codedefine($text); ?> Quote Link to comment Share on other sites More sharing options...
CyDrive Posted February 4, 2007 Author Share Posted February 4, 2007 Thank you that helps a lot i can now make the code that works around it. Quote Link to comment Share on other sites More sharing options...
CyDrive Posted February 4, 2007 Author Share Posted February 4, 2007 Sorry i cannot find the edit post button so.... I have implemented the code as you said but it dosent work. Though let me explain what im trying to do. I have a tutorial page on my site. The tutorials are read from a database as we'll as the content of the tutorial. I have evrything done but the actual displaying of the tutorials contents where i will also be able to store code. Here is the page that displays the tutorial. <? function code($content) {?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td bgcolor="#666666"><?echo $content; ?></td> </tr> </table> <? } include("header.php"); $tut = $_GET['tutorial']; $database = "usersystem"; $connection = mysql_connect($host, $user,$passwor) or die ("Could not connect to server."); $db = mysql_select_db($database, $connection) or die ("Could not select database."); $ret = mysql_query("SELECT * FROM tutorial"); $disp = mysql_result($ret,$tut,'content'); echo $disp; include("footer.php"); ?> Now say it pulls this from the database. <? code("<html>"); ?> it would display it like this. "); ?> Quote Link to comment Share on other sites More sharing options...
Orio Posted February 4, 2007 Share Posted February 4, 2007 Try this: <?php function codedefine($content) { echo " <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td bgcolor=\"#666666\">".htmlspecialchars($content)."</td> </tr> </table> "; } ?> Orio. 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.