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>"; } Link to comment https://forums.phpfreaks.com/topic/44665-mysql-function-help/ 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); ?> Link to comment https://forums.phpfreaks.com/topic/44665-mysql-function-help/#findComment-216964 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.