Forum Moderators: coopster
1-I run PHPmyfaq on my website (a script to crate and display FAQs on your website)
2-I have created a simple script that randomly displays a different FAQ record, everytime you load the home page.
3-Problem is, the whole FAQ article is displayed, and I don't want that. I simply want to dislpay the title of the record, then first 10 words of the article, and then a link for people to click and read the entire article. Like the following:
#*$!: A webmasters and Developers forum, where you can discuss.... (click to read more)
That is it. No more, no less.
Now for the code, this is what I have, but unfortunately, I am missing the code that will limit how many words are displayed, as well as the link to the entire article.
<?php
// Create the connection and select the DB
$link = mysql_connect("host","user","password");
if ($link) {
mysql_selectdb("db",$link);
// Select records from the DB
$query = "SELECT content FROM pmf_faqdata ORDER BY Rand() LIMIT 1";
$result = mysql_query($query);
// Display records from the table
echo "<table border='1'>";
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[1]</td></tr>";
}
echo "</table>";
} else {
echo "Can't connect to the database!";
}
?>
I would really appreciate if someone can help me in achieving this?
I also just read this on this forum from a day or two ago..
[webmasterworld.com ]
I got the first thing done.
The only thing left, is to hyperlink it, so people can click on the topic and read it in full
Article: This is an article about something...(click here to read more)
I would appreciate if someone can finish this for me please?
// Create the connection and select the DB
$link = mysql_connect("host","name","password");
if ($link) {
mysql_selectdb("password",$link);
// Select records from the DB
$query = "SELECT content,thema FROM pmf_faqdata ORDER BY Rand() LIMIT 1";
$result = mysql_query($query);
// Display records from the table
echo "<table border='1'>";
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo "<tr><td>".substr($row[1],0,50).substr($row[0],0,75)."...</td></tr>";
}
echo "</table>";
} else {
echo "Can't connect to the database!";
}