dennismonsewicz Posted July 1, 2008 Share Posted July 1, 2008 I have a while loop that is only grabbing one entry out of the database when there are multiple that it should be grabbing... $query = mysql_query("SELECT * FROM devotionals WHERE writer = 'dennis'"); while($results = mysql_fetch_array($query)) { $devotional_query = '<li><a href="#">' . $results['devotional_title'] . '</a></li>'; } there are at least two from the writer dennis. and it is only displaying one Quote Link to comment Share on other sites More sharing options...
revraz Posted July 1, 2008 Share Posted July 1, 2008 Appears you are overwriting $devotional_query with the last result. Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted July 1, 2008 Author Share Posted July 1, 2008 hmmm, how do you suggest going about fixing this? Quote Link to comment Share on other sites More sharing options...
lemmin Posted July 1, 2008 Share Posted July 1, 2008 Concatinate the strings: $devotional_query .= '<li><a href="#">' . $results['devotional_title'] .[...] Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted July 1, 2008 Author Share Posted July 1, 2008 ok so here is all of the code I am using $query = mysql_query("SELECT * FROM devotionals WHERE writer = 'dennis'"); while($results = mysql_fetch_array($query)) { $devotional_query = '<li><a href="#">' . $results['devotional_title'] . '</a></li>'; } $login = '<a class="title">Login</a> <div> <form action="index.php?action=login" method="post"> <label>Username:</label> <input type="text" name="username" id="username" /> <label>Password: </label> <input type="password" name="password" id="password" /> <input type="image" src="images/login.jpg" id="submit" /> </form> </div>'; $logout = '<a class="title">My Profile</a> <div> <ul> <li><a href="index.php">Home</a></li> <li><a href="profile.php?tool=changepw">Change Password</a></li> <li><a href="profile.php?tool=addfriend">Signup A Friend</a></li> <li><a href="index.php?action=logout">Logout</a></li> </ul> </div> <a class="title">Devotionals</a> <div> <ul> ' . $devotional_query . ' </ul> </div> <a class="title">Topics</a> <div> <ul> <li><a href="#">Testing</a></li> </ul> </div>'; I thought I could just call the variable $devotional_query? Quote Link to comment Share on other sites More sharing options...
lemmin Posted July 1, 2008 Share Posted July 1, 2008 As revraz said, you are overwriting the $devotional_query variable every time it loops. Add a period (.) right before the equals sign as I showed in my last post. Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted July 1, 2008 Author Share Posted July 1, 2008 ah gotcha... thanks for the help. Topic Solved! 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.