10-18-2012, 05:20 PM
And u can use this to display the icon.
Save it as icon.php.
then use it as that is id:row:col
<?php
$str = explode(':', $_GET['i']);
$id = $str[0];
$row = $str[1];
$col = $str[2];
// Create image instances
$src = imagecreatefrompng('data/icon/ItemBtn'.$id.'.png');
$dest = imagecreatetruecolor(32, 32);
$row_start = $row * 32;
$row_end = $row_start + 32;
$col_start = $col * 32;
$col_end = $col_start + 32;
// Copy
imagecopy($dest, $src, 0, 0, $col_start, $row_start, $col_end, $row_end);
// Output and free from memory
header('Content-Type: image/png');
imagepng($dest);
imagedestroy($dest);
imagedestroy($src);
?>
And this is what i use to display the inventory on my adminpanel
<?php
class Character
{
var $invenRows;
function GetInventory($cid)
{
global $db, $s;
$l = substr($cid, -1);
$query = sprintf
("
SELECT
*
FROM
%s.t_inven0%d
WHERE
a_char_idx = :cid
", $s->db,
$l );
$dbh = $db->prepare( $query );
$dbh->execute( array( ':cid' => $cid ) );
$count = $dbh->rowCount();
if( $count > 0 )
{
$i=0;
$result = $dbh->fetchAll();
foreach( $result as $row )
{
for($j=0; $j<5; $j++)
{
if( $row['a_item_idx' . $j] != '-1' )
{
$this->invenRows[$i]['id'] = $row['a_item_idx' . $j];
$this->invenRows[$i]['plus'] = $row['a_plus' . $j];
$this->invenRows[$i]['amount'] = $row['a_count' . $j];
$this->invenRows[$i]['flag'] = $row['a_flag' . $j];
$this->invenRows[$i]['opt0'] = $row['a_item' . $j . '_option0'];
$this->invenRows[$i]['opt1'] = $row['a_item' . $j . '_option1'];
$this->invenRows[$i]['opt2'] = $row['a_item' . $j . '_option2'];
$this->invenRows[$i]['opt3'] = $row['a_item' . $j . '_option3'];
$this->invenRows[$i]['opt4'] = $row['a_item' . $j . '_option4'];
$this->invenRows[$i]['row'] = $row['a_row_idx'];
$this->invenRows[$i]['col'] = $j;
$i++;
}
}
}
}
return $count;
}
}
?>
this gives u the array Character::invenRows[];

