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. Link to comment https://forums.phpfreaks.com/topic/37051-help-making-a-code-box/ 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); ?> Link to comment https://forums.phpfreaks.com/topic/37051-help-making-a-code-box/#findComment-176932 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. Link to comment https://forums.phpfreaks.com/topic/37051-help-making-a-code-box/#findComment-176942 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. "); ?> Link to comment https://forums.phpfreaks.com/topic/37051-help-making-a-code-box/#findComment-177005 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. Link to comment https://forums.phpfreaks.com/topic/37051-help-making-a-code-box/#findComment-177006 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.