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

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.