shauna7084 Posted March 28, 2007 Share Posted March 28, 2007 I am not a professional - but like to try my hand at PHP and mySQL occasionally. I'm stuck on something realatively easy. This function calls for a listing of all categories to be displayed. I'm wanting to change it to create a listing only of the current category (as defined by the ID in the URL). Can you help? function head() { global $mysql; $result = mysql_query("SELECT DISTINCT * FROM cats ORDER BY id", $mysql); while ($i = mysql_fetch_array($result)) { $cat = stripslashes($i[name]); } echo "<h1>Allegiance Answers</h1><h2>CURRENT CATEGORY HERE</h2><P><a href=search.php>Search for an Answer</a></p><br>"; } Quote Link to comment Share on other sites More sharing options...
Barand Posted March 28, 2007 Share Posted March 28, 2007 Do you mean <?php function head($id) { $result = mysql_query("SELECT name FROM cats WHERE id = '$id'"); $i = mysql_fetch_array($result) ; $cat = stripslashes($i[name]); echo "<h1>Allegiance Answers</h1><h2>$cat</h2><P><a href='search.php'>Search for an Answer</a></p>"; } $id = $_GET['id']; head ($id); ?> Quote Link to comment 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.