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
https://forums.phpfreaks.com/topic/107224-function-not-showing-all-results/
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);
}

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.