Jump to content

Archived

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

bladechob

Pop-up page for empty results search - the saga continues

Recommended Posts

Hi, Thorpe kindly gave me some code (if ([color=red]mysql_num_rows($result) == 0) {
  echo "We are sorry but the dates you have selected are either being provisionally held or not available. Please select another date range or contact Selina Brady on  01332 680 550 or info@southernsunresorts.co.uk</a>. Thank you.";) [/color] to slip into the search page below - however the message displayed appears even if the search returns with results. I'm thinking that this query needs to refer to the $queryab bit in the code as this particular search goes into a section of the sql called 'abacus' (an allocation table).

All input gratefully received! Code below:

<!--  abacus ========================================= -->
<?
}}

if ($pegabflagx=='1'){

$queryab = "SELECT abacus.*,
venue_main.hotelid,
venue_main.name,
  venue_main.groupname,
  venue_main.website,
  venue_main.graphic,
    venue_main.country,
  venue_main.notes,
  venue_main.kcflag,
  venue_main.terms,
  venue_main.postcode
from abacus,
venue_main
WHERE abacus.year='$year' and abacus.days like '%$dayssql%'
and  venue_main.hotelid='$hotelidx'  $sql2  and abacus.roomtype='$roomtype' and abacus.hotelid=venue_main.hotelid and abacus.alloname like '%$company%'  group by venue_main.hotelid";
//echo $queryab;
if (mysql_num_rows($result) == 0) {
  echo "We are sorry but the dates you have selected are either being provisionally held or not available. Please select another date range or contact Selina Brady on  01332 680 550 or info@southernsunresorts.co.uk</a>. Thank you.";
}
$resultab= mysql_db_query("$db", $queryab);
while ($r= mysql_fetch_array($resultab)) {
    $hotelid=$r["hotelid"];
    $allono=$r["allo"];
    $day=$r["days"];
    $year=$r["year"];
    $country=$r["country"];
    $kcflag=$r["kcflag"];
    $terms=$r["terms"];
    $postcode=$r["postcode"];
    $day=explode("|",$day);
    $allono=explode("|",$allono);
    $allorate=explode("|",$allorate);
    $allonor=array();
    $acount=count($day);
    //create the keys
    $allonop = array();
    $acount=count($day);
    for ($loopi=0;$loopi<$acount;$loopi++){
$temparray=array($day[$loopi] => $allono[$loopi]);
$allonop=$allonop+$temparray;
    }
    for ($loopi=0;$loopi<$acount;$loopi++){
$temparray=array($day[$loopi] => $allorate[$loopi]);
$allonor=$allonor+$temparray;
    }
    //print_r ($allonop);
    for ($loopi=$day_number_arrive;$loopi<$day_number_depart;$loopi++){
$loopi=sprintf ("%1.0f", $loopi);
if ($allonop[$loopi]>=$rooms){
    $ok='yes';
}
else{
    $ok='no';
   
}}
    //echo $days;
    if ($ok=='yes'){
    ?>
<form action="index.php?content=reg1" method="post">
  <input type="hidden" name="online" value="yes" >
  <input type="hidden" name="location" value="<?echo $location?>" >
<input type="hidden" name="hotelselect" value="<? echo$r["hotelid"]?>" >
<input type="hidden" name="rooms" value="<? echo$rooms?>" >
<input type="hidden" name="arrives" value="<? $newarrive=$arrives[0].$arrives[1]; echo$newarrive?>" >
<input type="hidden" name="days" value="<? echo$days?>" >
<input type="hidden" name="alloname" value="<?echo $r["alloname"]?>" >
<table summary="" border="0" width=80%>
<tr>
<td width="49" rowspan=3 valign=top><?php include('propertySubMenu.php'); ?>&nbsp;</td>

<td width="76" rowspan=3 valign=top><img src="http://images.cimnet.co.uk/<?echo $r["graphic"];?>" border="0"></td>
<td width="555" align=right><span class="style5"><b><? echo $r["name"]?>
        <?if ($country=='UNITED KINGDOM'){?>
      <a href="http://www.multimap.com/map/browse.cgi?client=public&db=pc&addr1=&client=public&addr2=&advanced=&addr3=&pc=<?echo $postcode?>&quicksearch=tn33+9eu&cidr_client=none" target=map>Map</a></b>
    <?}?>
                            <?if (($country=='FRANCE') or ($country=='France') ){?>
      <a href="http://www.mapquest.fr/cgi-bin/ia_find?link=btwn%2Ftwn-map_results&random=318&event=find_search&uid=u7x6hah508g7x9ha%3A25dutxuaaw&country=Great+Britain&SNVData=&address=&city=&Zip=<?echo $postcode?>&country=France&Find+Map.x=32&Find+Map.y=11" target=map>Map</a></b>
        <?}?>
        <input type="hidden" name="hotel" value="<? echo $r["name"]?>">
    <?if ($kcflag=='2'){?>
    <br>
    <img src="images/smileysparkle.gif" width="32" height="32">
    <?}?>
    </span></td>
</tr>
<tr>

<td align=right><div align="left" class="style7"><span class="style8"><? echo $r["notes"]?><br>
            <br>
    </span></div></td>
</tr>
<tr>
  <td align=right>&nbsp;</td>
  </tr>
<tr>

<td  align=right colspan=3><span class="style9">

        <?$query2 = "select ratename, rate, notes from venue_rates where hotelid='$hotelid'  and (ratename='$company' ) " ;
$result2= mysql_db_query("$db", $query2);
while ($r2= mysql_fetch_array($result2)) { ?>
<?echo $r2["ratename"]?> - <?echo $r2["rate"]?><br>
<?echo $r2["notes"]?><br>
<?}?>
The rate displayed is the property rental charge for the dates you have selected during the seasonal period, exclusive of supplements.    
<select name="rateselect">
                                  <?
//$query2 = "select ratename, rate, notes from venue_rates where hotelid='$hotelid'  and ratename like '%Southern Sun Resorts%' " ;

// Sep  7 2006 - JK@FL - fields are referenced by name when the result is used, so it's safe to add another, namely allorate and days
$query2="select abacus.days,abacus.allorate,abacus.alloname,abacus.rate, venue_main.name from abacus, venue_main where 1 and abacus.year='$year' and abacus.days like '%$dayssql%' and  venue_main.hotelid='$hotelid' and abacus.roomtype='$roomtype' and abacus.hotelid=venue_main.hotelid and abacus.alloname like '%$company%'";

if(!$result2= mysql_db_query("$db", $query2)){echo mysql_error();}
while ($r2= mysql_fetch_array($result2)) {
    // work out the rate and use that instead of the default
    $t_rate = sum_rates($dayssql, $r2["days"], $r2["allorate"]);
    ?>
   
  <option value="<?echo $t_rate?>"> &#163;<?echo $t_rate ?> - <?echo $r2["alloname"]?></option>
   

   
              <?}?>
            </select>
                <br>
                        <br>
                            <?echo $terms?><br>
                            All rates quoted are in <?echo $rx["currency"];?>
           
                            <input type="hidden" name="terms" value="<?echo $terms?>">
                            <br>
                            </span></td>
</tr>
<tr>

<td align=right colspan=3><input type="submit" value="Rate Details"></td>
</tr>


</table>
</form>
<table summary="" border="0" width=500>
<tr>
<td><hr></td>
</tr>
</table>
<!--  non allocated ========================================= -->

Share this post


Link to post
Share on other sites
Yes that should be  $resultab instead of $result.

A good idea when doing this sort of thing is to seperate it as follows.

$rows=mysql_num_rows($resultab);
echo $rows //for test purpose get rid of when live

if ($rows==0)
{
// do what you want here.
}

Share this post


Link to post
Share on other sites
Hi Steve, gave it a bash and works fine on blank returns but the message still appears on returning a positive search ???

Share this post


Link to post
Share on other sites
You shoud try adding a else statement like

if($rows=='0')
{
//Show that nothing was found
}
else
{
//DISPLAY FOUND DATA HERE
}

Dunno but that might help


Another would be to switch these around:
[code]
if (mysql_num_rows($result) == 0) {
  echo "We are sorry but the dates you have selected are either being provisionally held or not available. Please select another date range or contact Selina Brady on  01332 680 550 or info@southernsunresorts.co.uk[/url]. Thank you.";
}
$resultab= mysql_db_query("$db", $queryab); 
[/code]

Change To:

[code]
$resultab= mysql_db_query("$db", $queryab); 
if (mysql_num_rows($resultab) == 0) {
  echo "We are sorry but the dates you have selected are either being provisionally held or not available. Please select another date range or contact Selina Brady on  01332 680 550 or info@southernsunresorts.co.uk[/url]. Thank you.";
}
[/code]

Since you are asking for the number of rows before the query is even performed it will result with 0 try that it might help

Share this post


Link to post
Share on other sites
Gave it a go but no joy I'm afraid. Still displaying the message on successful returns... :-\

Share this post


Link to post
Share on other sites

$result= mysql_db_query($queryab); 
if (mysql_num_rows($result) == 0) {
  echo "We are sorry but the dates you have selected are either being provisionally held or not available. Please select another date range or contact Selina Brady on  01332 680 550 or info@southernsunresorts.co.uk[/url]. Thank you.";
}


try that

Share this post


Link to post
Share on other sites

×

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.