ianco Posted May 15, 2010 Share Posted May 15, 2010 Hi All, I have a list of database entries displayed as a menu i.e., Info1 Info2 Info3 etc. Each entry contains a news story. The question is: what php code do i need so that when i click on one of these links the related story appears in a page? My code so far for displaying a full list of entries is $sql="SELECT XMashTitle, XMashContent FROM XMash ORDER BY XMashID DESC"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $XMashTitle=$row["XMashTitle"]; $XMashContent=$row["XMashContent"]; $options.='<li class="blog"><b>' . $XMashTitle . "</b><br>" . $XMashContent . "</li>"; } mysql_close($con); ?> <ul class="blog"> <?=$options?> </ul><br> Quote Link to comment https://forums.phpfreaks.com/topic/201866-displaying-select-content-from-a-database/ Share on other sites More sharing options...
CodeMaster Posted May 16, 2010 Share Posted May 16, 2010 You might want to hire a freelancer for this. Quote Link to comment https://forums.phpfreaks.com/topic/201866-displaying-select-content-from-a-database/#findComment-1059062 Share on other sites More sharing options...
ianco Posted May 16, 2010 Author Share Posted May 16, 2010 Managed to solve it with the following if(isset($_GET['XMashID'])) { $id = $_GET['XMashID']; $q = mysql_query("SELECT * FROM XMash WHERE XMashID = $id") or die(mysql_error()); // display your info here for the single person $row = mysql_fetch_assoc($q); echo "<p><b>" . $row['XMashTitle'] . "</b><br>" . $row['XMashContent']."</p><br>"; } $q = mysql_query("SELECT * FROM XMash ORDER BY XMashID DESC LIMIT 10") or die(mysql_error()); while($r = mysql_fetch_array($q)) { $id = $r['XMashID']; $name = $r['XMashTitle']; echo "<a href='ScienceMash.php?XMashID=$id'>$name</a><BR>"; } Quote Link to comment https://forums.phpfreaks.com/topic/201866-displaying-select-content-from-a-database/#findComment-1059078 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.