Jump to content

[SOLVED] mysql_fetch_array only grabbing one entry


Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.