Topic: lite kod..
tänkte att jag skulle dela med mig eftersom jag har hafft en massa problem med det.. jag har så klart inte skrivit allt.. för jag var aldless för dum för att få min query att funka
men iaf.. scriptet gör så att man kan se dom senaste topicsarna, dom senast aktiva topicsarna, senaste postsen, senaste användaren, och senast aktiva användare
detta borde stå i dbinfo.php :
<?php
function kortaner($str, $length) {
return ((strlen($str) > $length)?(substr($str, 0, $length)."..."):($str));
}
$dbhost = "host";
$dbuser = "username";
$dbpass = "password";
$databas = "databas";
mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($databas);
$querys = array("senastetopics" => "SELECT id,subject,poster FROM punbb1topics ORDER BY posted DESC LIMIT 0, 5",
"aktivatopics" => "SELECT id,subject,poster,last_post_id FROM punbb1topics ORDER BY last_post DESC LIMIT 0, 5",
"senasteposts" => "SELECT id,message,topic_id,poster FROM punbb1posts ORDER BY posted DESC LIMIT 0, 5",
"senasteusern" => "SELECT id,username FROM punbb1users ORDER BY registered DESC LIMIT 0, 1",
"senastaktivausern" => "SELECT id,username FROM punbb1users ORDER BY last_post DESC LIMIT 0, 1",
"danews" => "SELECT punbb1topics.poster, punbb1topics.subject, punbb1topics.posted, punbb1posts.message FROM punbb1topics JOIN punbb1posts ON punbb1topics.id = punbb1posts.topic_id WHERE forum_id = 14 ORDER BY posted DESC"
);
foreach($querys as $k => $q) {
$query = mysql_query($q);
while($tmp = mysql_fetch_assoc($query)) {
$resultat[$k][] = $tmp;
}
//$antal[$k] = mysql_num_rows($query);
}
?>
sen så har vi whatever.php(min heter vissligen finfo.php om det tröstar er):
<?php
echo "<br><br>";
echo "senaste topics<br>";
foreach($resultat['senastetopics'] as $bleh) {
echo "<a href=\"forum/viewtopic.php?id={$bleh['id']}\" target=\"main\">".kortaner($bleh['subject'], 28)."</a><br>\n";
}
echo "<br><br>";
echo "aktiva topics<br>";
foreach($resultat['aktivatopics'] as $bleh) {
echo "<a href=\"forum/viewtopic.php?id={$bleh['id']}\" target=\"main\">".kortaner($bleh['subject'], 20)."</a><br>\n";
}
echo "<br><br>";
echo "sentaste posts<br>";
$length = 20;
foreach($resultat['senasteposts'] as $bleh) {
echo "<a href=\"forum/viewtopic.php?id={$bleh['topic_id']}#${bleh['id']}\" target=\"main\"><b>{$bleh['poster']}:</b> ".kortaner($bleh['message'], 18)."</a><br>\n";
}
echo "<br><br>";
echo "senaste usern: <b><a target=\"main\" href=\"forum/profile.php?id={$resultat['senasteusern'][0]['id']}\">{$resultat['senasteusern'][0]['username']}</a></b><br>\n";
echo "senast akriva usern: <b><a target=\"main\" href=\"forum/profile.php?id={$resultat['senastaktivausern'][0]['id']}\">{$resultat['senastaktivausern'][0]['username']}</a></b><br>\n";
?>
sen där vill ni vill ha dom så ere bara att skriva typ
<?php
include 'dbinfo.php'
?>
det måste stå i toppen av filen
sen bara
<?php
include 'finfo.php
?>
där du vill ha sjävla scriptet