Jump to content

help making a code box


CyDrive

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.