Location: PHPKode > projects > VampMan: V:tR Character Manager > vampman-1.0.2/phpnuke/modules/charactersheet/admin/charactersheet/mainfunctions.php
<?php
if ( !eregi( "admin.php", $_SERVER['PHP_SELF'] ) ) {
   die( "You can't access this file directly ..." );
}
require_once( "mainfile.php" );
global $prefix, $dbi;
$module_name = basename( dirname( __FILE__ ) );


function make_selectbox_enum($valuename, $valueresult) {
global $prefix, $dbi;
require_once( "mainfile.php" );
$display_block ="<select name=\"$valuename\">
<option value=\"\"> Choose a ".ucwords($valuename)."</option>";
$query = "SHOW COLUMNS FROM ".$prefix."_character_characters LIKE '".$valuename."'";
$result=sql_query("SHOW COLUMNS FROM ".$prefix."_character_characters LIKE '".$valuename."'", $dbi);

if(sql_num_rows($result, $dbi)>0){
$row=sql_fetch_row($result,$dbi);
$temp=explode("','",preg_replace("/(enum|set)\('(.+?)'\)/","\\2",$row[1]));
}

for ($m=0; $m < count($temp); $m++) {
	if("$temp[$m]" == "$valueresult")
	{        $display_block .= "<option value=\"$temp[$m]\" selected>
	        $temp[$m]</option>";
	}

	else{
        $display_block .= "<option value=\"$temp[$m]\">
        $temp[$m]</option>";}
}

$display_block .= "
</select>";
return $display_block;
}

function make_selectbox_num($valuename,$valueresult,$first,$last)
{
require_once( "mainfile.php" );
global $prefix, $dbi;
$display_block ="<select name=\"$valuename\">";

for ($m=$first; $m <= $last; $m++) {
       	if($m == $valueresult)
	{        $display_block .= "<option value=\"$m\" selected>
	        $m</option>";
	}

	else{
        $display_block .= "<option value=\"$m\">
        $m</option>";}

}
$display_block .= "
</select>";
return $display_block;
}

function make_selectbox_table($colname,$valuename,$table)
{

require_once( "mainfile.php" );
global $prefix, $dbi;
$result=sql_query("SELECT id,".$colname." FROM ".$prefix."_character_".$table." order by $colname", $dbi);

$display_block ="<SELECT name=$valuename>\n";
while ($line = mysql_fetch_array($result))
{
$display_block.= "<OPTION value='$line[id]'";
$display_block.= ">$line[$colname]</OPTION>\n";
}
$display_block.= "</SELECT>\n";
return $display_block;

}

function get_value($id,$valuename,$table) {

require_once( "mainfile.php" );
global $prefix, $dbi;
$display_block = "";
$result=sql_query("SELECT ".$valuename." FROM ".$prefix."_character_".$table." WHERE id='".$id."'", $dbi);
while($line = mysql_fetch_array($result))
{
	$display_block.= "$line[$valuename]";
}
return $display_block;
}

function stripquotes($string){
	return str_replace("\"","",stripslashes($string));
}
?>
Return current item: VampMan: V:tR Character Manager