Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.

I am trying to create a discussion board where you can click on the title of a post (from a list of many) to be taken to a page where only the post the user clicked on is displayed. I then want to put comments underneath.

However, I cant figure out how to display just 1 record instead of all of them in the database. (I think that is because of the array).

This is the code I have. it displays all the records in the database table instead of just showing 1.

PHP
<?php
		//connect to database
			require_once ('dbconnect.php');
$displayPosts = "select postID, postDate, postName, postTitle, postBody from pmf_discussion
                order by PostDate";
                $rsAllPosts = mysql_query($displayPosts);
                echo "<table id=\"posts\" border=\"1\">\n";
                while ($Post = mysql_fetch_array($rsAllPosts)){
                    $postID = $Post['postID'];
                    $postDate = $Post['postDate'];
                    $postName = $Post['postName'];
                    $postTitle = $Post['postTitle'];
		    $postBody = $Post['postBody'];
 
                    echo "<tr>
						<td>$postName</td>
						<td>$postBody</td>
					</tr>";
                }
                echo "</table>\n";
            ?>	
Posted
Comments
Mahesh Bailwal 24-Aug-13 13:56pm    
you need to use where clause in your sql statement for showing one record.

https://www.google.co.in/search?q=WCF+Failed+to+Add+Service.Service+Metadata+may+not+be+accessible.Make+Sure+your+Service+is+Running+and+exposing+metadata&oq=WCF+Failed+to+Add+Service.Service+Metadata+may+not+be+accessible.Make+Sure+your+Service+is+Running+and+exposing+metadata&aqs=chrome.0.69i57.340j0&sourceid=chrome&ie=UTF-8#fp=e7e24efeddcda2ea&q=mysql%20where%20clause
jba1991 24-Aug-13 14:12pm    
Ah cool thank you.

As soon as you mentioned a where clause it kind of ticked. Thanks again!
Mahesh Bailwal 24-Aug-13 14:47pm    
Please mark it solved :)

1 solution

Attach an id to each question, when a user clicks on a question and you can redirect your user to another page with the id of that question and then you can use the WHERE clause in the database to get that question only from the database on the basis of that id.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900