grey_goose
04-03-2016, 02:18 PM
I'm using Cel PHP in Custom BBCode (https://vborg.vbsupport.ru/showthread.php?t=264896).
- create a bbcode to list the past month's threads a given username has posted in.
<?php
$servername = "host";
$username = "username";
$password = "password";
$dbname = "database";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT thread.title, thread.threadid
FROM post
LEFT JOIN user ON (user.userid = post.userid)
LEFT JOIN thread ON (thread.threadid = post.threadid)
WHERE
post.username = '$value' AND
thread.`open` = 1 AND
thread.forumid NOT IN (2, 11, 15, 61, 191, 214, 289) AND
thread.lastpost >= UNIX_TIMESTAMP()-172800
GROUP BY
thread.title
ORDER BY
post.dateline DESC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$threads = '<a href="FQDN/forum/showthread.php?' . $row["threadid"]. '">' . $row["title"]. '</a><br>';
}
} else {
$threads = "0 results";
}
$conn->close();
return $threads;
?>
It works -- but only returns the first row. Help?
- create a bbcode to list the past month's threads a given username has posted in.
<?php
$servername = "host";
$username = "username";
$password = "password";
$dbname = "database";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT thread.title, thread.threadid
FROM post
LEFT JOIN user ON (user.userid = post.userid)
LEFT JOIN thread ON (thread.threadid = post.threadid)
WHERE
post.username = '$value' AND
thread.`open` = 1 AND
thread.forumid NOT IN (2, 11, 15, 61, 191, 214, 289) AND
thread.lastpost >= UNIX_TIMESTAMP()-172800
GROUP BY
thread.title
ORDER BY
post.dateline DESC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$threads = '<a href="FQDN/forum/showthread.php?' . $row["threadid"]. '">' . $row["title"]. '</a><br>';
}
} else {
$threads = "0 results";
}
$conn->close();
return $threads;
?>
It works -- but only returns the first row. Help?