I'm trying to get the topics data table from my forum's MySQL database fed onto my website.
I went into the PhpMyAdmin and I changed the SQL code of the base to PHP and got this:
PHP Code:
$sql = 'SELECT * FROM `forums_topics` LIMIT 0, 30 ';
I don't know much about PHP, but I've seen it alot, so I took a guess at how to implement it into my site.
Here's what I did:
PHP Code:
<?php
$sql = 'SELECT * FROM `forums_topics` LIMIT 0, 30 ';
?>
But whatever code that is in the section that I want the feed to be in has to be in between <li></li> tags, and I do not know how to put those into PHP, which is what I'm assuming is making the above code not work.
What happens is just a "." where the feed should be.
Does anyone know if this is the problem, and if so, how can I fix it?
The code you have added just constructs the query, after it you will have to execute it, get the result returned in an array and then run a while loop or foreach on this array to populate the <li>.
Alright, I used the example on the page and edited everything I could find.
What do I have to put as my row? Because I think I'm getting my rows and columns mixed up. Because when I try to run this, it shows me this:
if (!$conn) {
echo "Unable to connect to DB: " . mysql_error();
exit;
}
if (!mysql_select_db("ashint_forums")) {
echo "Unable to select mydbname: " . mysql_error();
exit;
}
$sql = "SELECT title as title
FROM forums_topics
WHERE title = 1";
$result = mysql_query($sql);
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print, so am exiting";
exit;
}
// While a row of data exists, put that row in $row as an associative array
// Note: If you're expecting just one row, no need to use a loop
// Note: If you put extract($row); inside the following loop, you'll
// then create $userid, $fullname, and $userstatus
while ($row = mysql_fetch_assoc($result)) {
echo $row["title"];
}
is the default thing, however im not sure what the url up top shows as, im guessing it would be like yourwebsite.com/forum/showthread.php?t=1234 so then assuming t is like the column id then it would be:
Bookmarks