SimplePortal
Customization => Blocks and Modifications => Block Requests => Topic started by: Columbo on September 24, 2013, 03:40:20 PM
-
Hi there,
I'd like to start using SP to display snippets of non forum information from my db,
eg.
In my smf database I have an additional table called "vehicles" with fields "name" & "car"
& the table will only ever have up to 20 lines
how would I display the table in a SP PHP block ?
Thanks
Columbo
-
Welcome to SimplePortal!
I don't know the database structure you have there but the code should look something similar to the following:
global $smcFunc;
$request = $smcFunc['db_query']('', '
SELECT name, car
FROM {db_prefix}vehichles',
array(
)
);
$vehicles = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$vehicles[] = array(
'name' => $row['name'],
'car' => $row['car'],
);
}
$smcFunc['db_free_result']($request);
echo '
<table>
<tr>
<th>Name</th>
<th>Car</th>
</tr>';
foreach ($vehicles as $vehicle)
{
echo '
<tr>
<td>', $vehicle['name'], '</td>
<td>', $vehicle['car'], '</td>
</tr>';
}
echo '
</table>';
-
Exactly what I need,
thank you very much SiNaN
:thumbsup: