# \[PHP\] If no results

**URL:** <https://forum.kirupa.com/t/php-if-no-results/191099>\
**Category:** Uncategorized\
**Created:** [June 17, 2006, 5:34am UTC](https://forum.kirupa.com/t/php-if-no-results/191099 "2006-06-17T05:34:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![evileks](https://avatars.discourse-cdn.com/v4/letter/e/cab0a1/32.png) [@evileks](https://forum.kirupa.com/u/evileks)\
**Post date:** [June 17, 2006, 5:34am UTC](https://forum.kirupa.com/t/php-if-no-results/191099/1 "2006-06-17T05:34:57Z")

</div>

Hello, I’m using the following code to get a list of articles defined by the input the user selects. When the page loads it first displays the lastest news articles from my database, and if the user selects a section to get the news from using a dropdown menu form it will show news from that selection instead.

My question is how to get it to display a “no results” messege. Any ideas anyone?

```php
<?php
/////////If the user selects what section
if ($HTTP_POST_VARS){
echo '<p>Articles:<p>';
$section = $HTTP_POST_VARS['section'];
// Require the database class
require_once('../includes/DbConnector.php');

// Create an object (instance) of the DbConnector
$connector = new DbConnector();

// Execute the query to retrieve articles
$result = $connector->query("SELECT ID,title,tagline FROM cmsarticles WHERE section = $section ORDER BY ID DESC LIMIT 0,50");

// Get an array containing the results.
// Loop for each item in that array
while ($row = $connector->fetchArray($result)){

echo "<a href='article.php?id=".$row['ID']."'>";
echo $row['title'];
echo '</a><br>';
echo $row['tagline'];
echo '<p>';
}
}
///////////////////
else{
echo '<p>New Articles:<p>';
// Require the database class
require_once('../includes/DbConnector.php');

// Create an object (instance) of the DbConnector
$connector = new DbConnector();

// Execute the query to retrieve articles
$result = $connector->query('SELECT ID,title,tagline FROM cmsarticles ORDER BY id DESC LIMIT 0,20');

// Get an array containing the results.
// Loop for each item in that array
while ($row = $connector->fetchArray($result)){

echo "<a href='article.php?id=".$row['ID']."'>";
echo $row['title'];
echo '</a><br>';
echo $row['tagline'];
echo '<p>';
}
}
?>

```
