Jump to content

Function : Not showing all results.


a1amattyj

Recommended Posts

Hello,

 

Function:

 

function News()
{
    mysql_close($conn2);

    require ('multi_operations/config_inc.php');

    $query = "SELECT * FROM multi_news ORDER BY id DESC";
    $result = mysql_query($query) or die(mysql_error());
    $row2 = mysql_fetch_array($result);

    if ($row2['status'] == '1') {

while($row2 = mysql_fetch_array($result)){
echo '			
	<table width="100%" cellpadding="3" cellspacing="1" border="0" class="bordercolor">
             <tr class="titlebg">
			<td align="center" colspan="2" class="largetext"><b>'.$row2['subject'].' - '.$row2['date'].'</b></td>
		</tr>

<tr>
			<td class="windowbg" valign="top" style="padding: 7px;">

				<div style="font-size: 0.85em">'.$row2['message'].'</div>

			</td>
		</tr>
	</table>

';
}

    }
    mysql_close($conn);
}

 

However, with the select mysql ^

 

if there is one result in the database, it will not display it.

If there is a second result in the database, it will display the first one.

if i insert a third result, it will show the last two but not the most recent one.

 

So basically, it is not displaying the most recent one.

 

Thanks

Link to comment
Share on other sites

function News()
{
    mysql_close($conn2);

    require ('multi_operations/config_inc.php');

    $query = "SELECT * FROM multi_news WHERE `status`='1' ORDER BY id DESC";
    $result = mysql_query($query) or die(mysql_error());
//    $row2 = mysql_fetch_array($result);

//    if ($row2['status'] == '1') {

while($row2 = mysql_fetch_array($result)){
echo '			
	<table width="100%" cellpadding="3" cellspacing="1" border="0" class="bordercolor">
             <tr class="titlebg">
			<td align="center" colspan="2" class="largetext"><b>'.$row2['subject'].' - '.$row2['date'].'</b></td>
		</tr>

<tr>
			<td class="windowbg" valign="top" style="padding: 7px;">

				<div style="font-size: 0.85em">'.$row2['message'].'</div>

			</td>
		</tr>
	</table>

';
}

//    }
    mysql_close($conn);
}

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.