bigggnick Posted September 11, 2007 Share Posted September 11, 2007 Hey all, I'm making a system for managing articles on my site, and I was wondering if i could do a line like this: $result = mysql_query("SELECT article_content, auth_name FROM articles WHERE article_name='$article_name' ORDER BY article_name"); while($row = mysql_fetch_array($result, MYSQL_BOTH)){ echo '<h1>' . $row[article_name] . '</h1>'; echo 'By:' . $row[auth_name]; echo $row[article_content]; an example of the URL would be articles.php?article_name=test Would this work? Thanks Link to comment https://forums.phpfreaks.com/topic/68925-order-by-question/ Share on other sites More sharing options...
liebs19 Posted September 11, 2007 Share Posted September 11, 2007 If you are send the information through the $_GET method you will need to first pull it out into a variable. $article_name = $_GET['article_name']; $result = mysql_query("SELECT article_content, auth_name FROM articles WHERE article_name='" . $article_name . "' ORDER BY '" . $article_name . "'"); while($row = mysql_fetch_array($result, MYSQL_BOTH)){ echo '<h1>' . $article_name . '</h1>'; // to use the $row[article_name] here you need to request article_name in your query echo 'By:' . $row[auth_name]; echo $row[article_content]; } I did not test this code, but the basics are that you first need to get the data from the URL before using it in the query. Link to comment https://forums.phpfreaks.com/topic/68925-order-by-question/#findComment-346466 Share on other sites More sharing options...
bigggnick Posted September 11, 2007 Author Share Posted September 11, 2007 Thanks for the reply, I'll give that a shot. Link to comment https://forums.phpfreaks.com/topic/68925-order-by-question/#findComment-346473 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.