php code into a custom block

Current Version: 1.0.6
Released: 09.01.10
Forum rules
Before creating a new support thread, please take a look in the board3 Portal FAQ and use the search!
Many questions have already been answered.
Locked

Topic author
Keroppi
Active Member
Posts: 1
Joined: 4. October 2008 23:17

php code into a custom block

Post by Keroppi »

Your Portal Version: 1.0.0RC3
Your phpBB Type: Standard phpBB3
MODs installed: No
Your knowledge: Beginner

What have you done before the problem was there?


What have you already tryed to solve the problem?


Description and Message
Hi guys, I hope you can help.
I suppose my question is quite newbish cause I'm not a skilled php coder ;) but here's my problem:

I need to insert into a custom block some php code; I'm basically loading data from an external application (though the database is THE SAME as the phpBB one but I don't know how to use global var) but the problem is I don't know how to let html parse my php code.

Here's the code for myblock.html

Code: Select all

<div class="portal-panel">
	<div class="inner">
		<span class="portal-corners-top"><span></span></span>
			<h3>&nbsp;Raid Calendar</h3>
			<div style="text-align: center;">

<?

// Connecting, selecting database

$dbname = "xxx";
$username = "xxx";
$password = "xxx";
$hostname = "xxx";

$connection = mysql_connect("$hostname", "$username", "$password") or die("couldn't connect to database server");
$db = mysql_select_db("$dbname", $connection) or die("Couldn't select database");


// Performing SQL query
$query = 'SELECT * FROM phpraider_raid where expired = 0 order by start_time asc';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());


// Printing results in HTML
while ($line = mysql_fetch_array($result)) {

      //set raid variables
      $raid_id = $line["raid_id"];
      $loc = $line["location"];
      $desc = $line["description"];      
      $start = $line["start_time"];
      $max = $line["maximum"];
      $icon = $line["icon_name"];
      $raid_leader["raid_leader"];

      //query for approved
      $query = 'SELECT * FROM phpraider_signups where queue = 0 and cancel = 0 and raid_id = '.$raid_id;
      $result2 = mysql_query($query) or die('Query failed: ' . mysql_error());
      $apprvd = mysql_num_rows($result2);

      //query for Queued
      $query = 'SELECT * FROM phpraider_signups where queue = 1 and cancel = 0 and raid_id = '.$raid_id;
      $result3 = mysql_query($query) or die('Query failed: ' . mysql_error());
      $que = mysql_num_rows($result3);

      //build display table

	echo "<img src=\"http://www.mysite.com/phpBB/Raider/games/WoW/images/raids/$icon\" title=\"$loc\" alt=\"$loc\"/> " . gmdate("D j M, H:i", $start) . "<br />$apprvd/$max ($que)<br /><hr>\n";
}

?>

			</div>
			<br />
		<span class="portal-corners-bottom"><span></span></span>
	</div>
</div>
<br style="clear:both" />
[/i]
Locked

Return to “board3 Portal 1.0.x - English Support”