Jump to content


Photo

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


  • Please log in to reply
7 replies to this topic

#1 bladechob

bladechob
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts
  • LocationDerby, UK

Posted 26 September 2006 - 06:51 AM

Hi, Thorpe kindly gave me some 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</a>. Thank you.";)
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....ddr3=&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....ity=&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 ========================================= -->
To forgive is to forget... to forget is... what was I saying?

#2 steveclondon

steveclondon
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 26 September 2006 - 07:16 AM

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.
}


#3 bladechob

bladechob
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts
  • LocationDerby, UK

Posted 26 September 2006 - 07:28 AM

Thanks for that Steve, I'll paste it in and see what happens
To forgive is to forget... to forget is... what was I saying?

#4 bladechob

bladechob
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts
  • LocationDerby, UK

Posted 26 September 2006 - 07:43 AM

Hi Steve, gave it a bash and works fine on blank returns but the message still appears on returning a positive search ???
To forgive is to forget... to forget is... what was I saying?

#5 skatermike21988

skatermike21988
  • Members
  • PipPipPip
  • Advanced Member
  • 100 posts
  • LocationFlorida

Posted 26 September 2006 - 07:49 AM

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:
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);   

Change To:

$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."; 
}

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


#6 bladechob

bladechob
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts
  • LocationDerby, UK

Posted 26 September 2006 - 08:13 AM

Gave it a go but no joy I'm afraid. Still displaying the message on successful returns... :-\
To forgive is to forget... to forget is... what was I saying?

#7 skatermike21988

skatermike21988
  • Members
  • PipPipPip
  • Advanced Member
  • 100 posts
  • LocationFlorida

Posted 26 September 2006 - 08:22 AM


$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


#8 bladechob

bladechob
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts
  • LocationDerby, UK

Posted 26 September 2006 - 08:55 AM

Nope - still not having it, but appreciate your help though
To forgive is to forget... to forget is... what was I saying?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users