RoutineX
03-10-2006, 07:32 AM
I've been doing some reading and apparently you can't use PHP directly in the templates. The php code works perfectly standalone, but wanted to integrate it in a vBulletin template. I've made a plugin in global_start with the php code I want to use, but wasn't sure what to do next (if that even was right). I also read some in the API documentation, but didn't manage to get any further with that.
What I want to do is basically just connect to a database, selecting everything from a table and displaying it in a table(html) and print row for row.
Below is the code of what I'm going to do (just edited the values).
Hope anyone can help :)
require ('auth.php');
$res = mysql_query("SELECT * FROM TableName",$db);
$test = 1;
if($rad = mysql_fetch_array($res))
{
echo'
<table width="642" border="0" cellspacing="0">
<tr bordercolor="#CCFF33">
<td width="XX"><strong>Topic 1</strong></div></td>
<td width="XX"><strong>Topic 2</strong></div></td>
</tr>
';
do {
printf("<tr bordercolor=\"#CCFF33\">
<td background=\"XXX.jpg\">%s</td>
<td background=\"XXX.jpg\">%s</td>
<td background=\"XXX.jpg\">%s</td>
</tr>\n",
$test,
$rad["Topic 1"],
$rad["Topic 2"]);
$test++;
}
while ($rad = mysql_fetch_array($res));
echo "</table>\n";
}
?>
What I want to do is basically just connect to a database, selecting everything from a table and displaying it in a table(html) and print row for row.
Below is the code of what I'm going to do (just edited the values).
Hope anyone can help :)
require ('auth.php');
$res = mysql_query("SELECT * FROM TableName",$db);
$test = 1;
if($rad = mysql_fetch_array($res))
{
echo'
<table width="642" border="0" cellspacing="0">
<tr bordercolor="#CCFF33">
<td width="XX"><strong>Topic 1</strong></div></td>
<td width="XX"><strong>Topic 2</strong></div></td>
</tr>
';
do {
printf("<tr bordercolor=\"#CCFF33\">
<td background=\"XXX.jpg\">%s</td>
<td background=\"XXX.jpg\">%s</td>
<td background=\"XXX.jpg\">%s</td>
</tr>\n",
$test,
$rad["Topic 1"],
$rad["Topic 2"]);
$test++;
}
while ($rad = mysql_fetch_array($res));
echo "</table>\n";
}
?>