Trying to Create a FAQ page but using the same code as a seestore example.


#1

Hi All,

So I am trying to create my own basic photography studio website…sort of a little project. I want to learn the language as best as I can but it is quite difficult as I am on my own studying this. I worked through a book "Sams Teach Yoursel PHP, MySQL, and Apache and now after finishing it I am working on my website. I am currently trying to create a FAQ page based on the seestore.php example that was in the book. I changed the code to work specifically for my needs and I have the example questions and answers etc in my database. The problem is it won’t work. I can see the other parts of that page i.e. the background color, navigation bar etc, but the actual questions and answer parts won’t work. Below is my code! If someone could help me it would be very much appreciated!

[code]

ul { list-style-type:none; margin:0; padding:0; overflow:hidden; } li { float:left; } a:link,a:visited { display:block; width:120px; font-weight:bold; color:#FFFFFF; background-color:#98bf21; text-align:center; padding:4px; text-decoration:none; text-transform:uppercase; } a:hover,a:active { background-color:#7A991A; }

L. Mo's Photography

F.A.Q.

    div.img { margin: 2px; border: 1px solid #0000ff; height: auto; width: auto; float: left; text-align: center; } div.img img { display: inline; margin: 3px; border: 1px solid #ffffff; } div.img a:hover img {border: 1px solid #0000ff;} div.desc { text-align: center; font-weight: normal; width: 120px; margin: 2px; }
[/code]

[php]

<?php //connect to database $mysqli = mysqli_connect("localhost", "root", "", "photo studio"); $display_block = "

Please select a category to view the relevant questions.

"; //show categories first $get_cats_sql = "SELECT id, cat_title, cat_desc FROM faq_categories ORDER BY id"; $get_cats_res = mysqli_query($mysqli, $get_cats_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($get_cats_res) < 1) { $display_block = "

Sorry, no categories to browse.

"; } else { while ($cats = mysqli_fetch_array($get_cats_res)) { $cat_id = $cats['id']; $cat_title = strtoupper(stripslashes($cats['cat_title'])); $cat_desc = stripslashes($cats['cat_desc']); $display_block .= "

".$cat_title."
" .$cat_desc."

"; if (isset($_GET["cat_id"])) { if ($_GET["cat_id"] == $cat_id) { //get questions $get_questions_sql = "SELECT id, question FROM faq_questions WHERE cat_id - ;".$cat_id."; ORDER BY id"; $get_questions_res = mysqli_query($mysqli, $get_questions_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($get_questions_res) <1) { $display_block = "

Sorry, no questions in this category.

"; } else { $display_block .= "
    "; while ($questions = mysqli_fetch_sarray($get_items_res)) { $id = $questions['id']; $questions= stripslashes($questions['question']); $display_block .= "
  • ".$questions." (\$".$item_price.")
  • "; } $display_block .= "
"; } //free results mysqli_free_results($get_questions_res); } } } } //free results mysqli_free_result($get_cats_res); //close connection to MySQL mysqli_close($mysqli); ?>

[/php]

<html>
<head>
<title>F.A.Q.</title>
</head>
<body>
<?php echo $display_block; ?>
</body>
</html>






</td>
</tr>
</p>
</table>
</body>
</body>
</html>

Thanks a million in advance! I hope that I did the php/code marks correct!

Leah


#2

Is this the code? I haven’t looked past the HTML yet, but it looks like a cut-and-paste accident.
How many tags do you need?
I’m going to take a look at your problem, but you may want to reread what you posted.

O.


#3

yeah that is the code. I got it all from an example and then tweaked it a bit to suit me but all the tags were there