Codice PHP:
<h2>FAQ</h2>
<?php
include("common.php");
#Connect to DB
$db_connection = mysql_connect ($db_server, $db_username, $db_password);
$db_selected = mysql_select_db($db_name, $db_connection);
if (! $db_selected)
{
echo('Unable to connect to Database');
}
#Check for mode. "all" displays all question/answer pairs
$mode=$_POST[mode];
echo $mode;
if ($mode=="all")
{
$result = mysql_query("SELECT * from q_a ORDER BY counter DESC",$db_connection);
while ($row =mysql_fetch_array ($result) )
{
print("[b]$row[question][/b]
$row[answer]
");
}
} else {
#Check for specific question id and display only that question.
if ($id)
{
$result = mysql_query("SELECT * from q_a WHERE id = $id",$db_connection);
$row = mysql_fetch_array($result);
print("[b]$row[question][/b]
$row[answer]");
#increment the counter for the question
$i = $row[counter];
$i++;
mysql_query("UPDATE q_a SET counter = $i WHERE id=$id",$db_connection);
} else {
?>
Below is the list of questions. Click to get the answer.
<h3>FAQ - [url="listquestions.php?mode=all"]All questions[/url]</h3>
<?php
#Generate list of questions with links to detail
$result = mysql_query("SELECT * from q_a ORDER BY counter DESC",$db_connection);
while ($row =mysql_fetch_array ($result) )
{
print("<a href=listquestions.php?id=$row[id]>$row[question]</a>
");
}
}
}
voi riuscite a capire questo script per le faq come funziona??? a me non funge..