bladechob Posted June 17, 2007 Share Posted June 17, 2007 Hi, I've got a page where it seraches a database and returns hotel info. On the page returned it also has a behaviour that highlights whether a particular venue has been 'blacklisted'. I need to add a further behaviour that indicates whether a particular venue is commissionable or not - if not it should highlight that venue as being non-commissionable. I've tried various means of inserting the additional 'warning' but the page just crashes out. Where am I going wrong with this? Base page code below. In a nutshell I've set up the sql - written from another page so that to simple radio buttons indicate noncomm or not: <? error_reporting(0); session_start(); //if(!isset($_SESSION["userid"])){ //header("Location:index.htm"); //echo "logon failed"; //exit; //} if(!empty($_GET['session'])){ unset($_SESSION['sql']); } //echo $sql; ?> <html> <!-- Creation date: 14/08/2003 --> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title></title> <meta name="description" content=""> <meta name="keywords" content=""> <meta name="author" content="Lathyrus Ltd"> <meta name="generator" content="AceHTML 5 Pro"> <link rel="StyleSheet" type="text/css" href="style.css"> <script language="JavaScript"> function blackListAlert(){ alert('You have selected a blacklisted hotel. This may be because the client has insisted on this venue. If you have selected this hotel in error, or the client is happy to use a different venue, please choose a different one immediately. You can do this by clicking the "Change Hotel" link in the venue details section on the left of the screen."'); } </script><style type="text/css"> <!-- body { background-color: #ccffcc; } --> </style></head> <body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0"> <table summary="" border="0" width="100%" height="100%" bgcolor="white"> <tr> <td valign="top"> <? require_once("cfg.php"); require_once($CFG->include_dir . "/config.php"); require_once($CFG->include_dir . "/weblib.php"); require_once($CFG->include_dir . "/dblib.php"); if (!isset($search) && !isset($_SESSION['sql'])){ ?> <form action="<?PHP $_SERVER['PHP_SELF'];?>" method="POST"> <table border="0" cellpadding=0 bgcolor="#ccffcc" class="hotel" summary=""> <tr> <td>Hotel Number</td> <td><input type="text" name="searchhotelid" size="20" maxlength="256"></td><!-- *** --> </tr> <tr> <td>Hotel name</td> <td><input type="text" name="searchname" size="50" maxlength="256"></td><!-- *** --> </tr> <tr> <td>Preferred by </td> <td><input type="text" name="searchpreferred" size="50" maxlength="256"></td><!-- *** --> </tr> <tr> <td>Hotel Town</td> <td><input type="text" name="searchtown" size="50" maxlength="256"></td><!-- *** --> </tr> <tr> <td>County</td> <td><input type="text" name="searchcounty" size="50" maxlength="256"></td><!-- *** --> </tr> <tr> <td>Country</td> <td><input type="text" name="searchcountry" size="50" maxlength="256"></td><!-- *** --> </tr> <tr> <td>Postcode</td> <td><input type="text" name="searchpost" size="50" maxlength="256"></td><!-- *** --> </tr> <tr> <td>Region</td> <td><select name="searchregion"> <option></option> <? dbconnect(); $queryu = "select list from lists where name='region' "; $resultu=mysql_query($queryu,$conn); $list=mysql_result($resultu,0,0); $list = preg_replace("/(\015\012)|(\015)|(\012)/","@",$list); $list_array=explode ("@", $list); $count=count($list_array); for ($loopi=0;$loopi<$count;++$loopi){ $this=$list_array[$loopi];?> <option <? if ($this==$hotel_region){echo ' selected';}?>> <? echo $list_array[$loopi];?></option> <? }?> </select></td><!--dd--> </tr> <tr> <td>Rating</td> <td><select name="searchrating"> <option></option> <? dbconnect(); $queryu = "select list from lists where name='cimrating' "; $resultu=mysql_query($queryu,$conn); $list=mysql_result($resultu,0,0); $list = preg_replace("/(\015\012)|(\015)|(\012)/","@",$list); $list_array=explode ("@", $list); $count=count($list_array); for ($loopi=0;$loopi<$count;++$loopi){ $this=$list_array[$loopi];?> <option <? if ($this==$hotel_rating){echo ' selected';}?>> <? echo $list_array[$loopi];?></option> <? }?> </select></td><!--dd--> </tr> <tr> <td>Type</td> <td><select name="searchtype"> <option></option> <? dbconnect(); $queryu = "select list from lists where name='venuetype' "; $resultu=mysql_query($queryu,$conn); $list=mysql_result($resultu,0,0); $list = preg_replace("/(\015\012)|(\015)|(\012)/","@",$list); $list_array=explode ("@", $list); $count=count($list_array); for ($loopi=0;$loopi<$count;++$loopi){ $this=$list_array[$loopi];?> <option <? if ($this==$hotel_type){echo ' selected';}?>> <? echo $list_array[$loopi];?></option> <? }?> </select></td><!-- *** --> </tr> <tr> <td>Rooms</td> <td><input type="text" name="searchrooms" size="20" maxlength="256"></td><!-- *** --> </tr> <tr> <td>Hotel Group</td> <td><input type="text" name="searchgroup" size="50" maxlength="256"></td><!-- *** --> </tr> <tr> <td> </td> <td> </td> <tr> <td>Room style capacity</td> <td> <table summary="" border="0"> <tr> <td>Banquet </td> <td> <input type="text" name="searchba" size="5" maxlength="5" ></td> <td>Boardroom</td> <td><input type="text" name="searchbo" size="5" maxlength="5" ></td> </tr> <tr> <td>Classroom</td> <td><input type="text" name="searchc" size="5" maxlength="5" ></td> <td>Theatre </td> <td><input type="text" name="searcht" size="5" maxlength="5" ></td> </tr> <tr> <td>U Shaped</td> <td><input type="text" name="searchu" size="5" maxlength="5" ></td> <td>Maximum</td> <td><input type="text" name="searchm" size="5" maxlength="256" ></td> </tr> </table></td> </tr> <tr> <td> <? if (isset($clientid)){echo '<input type=hidden name=clientid value='.$clientid.'>';}?> <input type="hidden" name="search" value="1"> <input type="hidden" name="source" value="<? echo $source?>"> <input name="submit" type="submit" class=button value="Search"></td> </tr> </table> </form> <? } else{ //if(isset($search)){unset($_SESSION['sql']);} if ($searchname!=''){ $sql1=' and venue_main.name like \'%'.trim($searchname).'%\''; } if (!empty($_REQUEST['searchtown'])){ $sql2=' and venue_main.town like \'%'.$searchtown.'%\''; } if ($searchgroup!=''){ $sql3=' and venue_main.groupname like \'%'.$searchgroup.'%\''; } if ($searchhotelid!=''){ $sql4=' and venue_main.hotelid=\'%'.$searchhotelid.'%\' '; } if ($searchpost!=''){ $sql5=' and venue_main.postcode like \'%'.$searchpost.'%\''; } if ($searchrooms!=''){ $sql6=' and venue_main.rooms> \'%'.$searchrooms.'%\' '; } if ($searchcounty!=''){ $sql7=' and venue_main.county like \'%'.$searchcounty.'%\' '; } if ($searchcountry!=''){ $sql7a=' and venue_main.country like \'%'.$searchcountry.'%\' '; } if ($searchregion!=''){ $sql8=' and venue_main.region like \'%'.$searchregion.'%\' '; } if ($searchrating!=''){ $sql9=' and venue_main.rating like \'%'.$searchrating.'%\' '; } if ($searchtype!=''){ $sql10=' and venue_main.type like \'%'.$searchtype.'%\' '; } if (!empty($searcht) || !empty($searchm)){ if(!empty($searcht)){ $sfilter=$searcht; }else{ $sfilter=$searchm; } $sqls=', venue_rooms'; $sql11=' and venue_main.hotelid=venue_rooms.hotelid and venue_rooms.theatre >= \''.$sfilter.'\' '; } if ($searchpreferred!=''){ $sql12=' and venue_main.preferred like \'%'.trim($searchpreferred).'%\''; } if (!isset ($sql)){ $sql=$sql1.$sql2.$sql3.$sql4.$sql5.$sql6.$sql7.$sql7a.$sql8.$sql9.$sql10.$sql11.$sql12; $_SESSION['sql']=$sql; } if(isset($_SESSION['sql'])){$sql=$_SESSION['sql'];} $sql=stripslashes($sql); ?> <table summary="" border="0" class=hotel> <tr> <td colspan="2"></td> <td align="right" colspan="3"><a href="<? echo "search_hotel.php?session=kill&source=$source"; ?>"><b>New Search</b></a></td><!-- *** --> </tr> <tr><td colspan=7> Order by -<br> </td></tr> <form action="<?PHP $_SERVER['PHP_SELF'];?>" method="POST"> <input type="hidden" name="search" value="1"> <input type="hidden" name="source" value="<? echo $source?>"> <input type="hidden" name="sql" value="<? echo $sql?>"> <tr> <td ><input name='Hotel/Venue' type="submit" value="Hotel/Venue" ></td> <td ><input name='Preferred' type="submit" value="Preferred" ></td> <td><input name='Town' type="submit" value="Town"></td> <td><input name='Group' type="submit" value="Group" ></td> <td><input name='Rooms' type="submit" value="Rooms" ></td> <td><input name='Rate' type="submit" value="Rate" ></td> <td></td> </tr> </form> <tr><td colspan=7><hr></td></tr> <? //echo $_POST['Hotel/Venue']; //echo $order; if (!isset ($order)){$order='order by venue_main.town ';} if ($_POST['Hotel/Venue']=="Hotel/Venue"){$order='order by '.name;} if ($_POST['Preferred']=="Preferred"){$order='order by '.preferred;} if ($_POST['Town']=="Town"){$order='order by '.town;} if ($_POST['Group']=="Group"){$order='order by '.groupname;} if ($_POST['Rooms']=="Rooms"){$order='order by '.rooms;} if ($_POST['Rate']=="Rate"){$order='order by rate desc';} if(isset($_SESSION['sql'])){$sql=$_SESSION['sql'];} //if(isset($_SESSION['order'])){$order=$_SESSION['order'];} dbconnect(); $query = "select venue_main.hotelid, venue_main.name, venue_main.town, venue_main.groupname, venue_main.rooms, venue_main.preferred, venue_main.blacklisted from venue_main $sqls where 1 $sql group by venue_main.hotelid $order"; if(!$result=mysql_query($query,$conn))echo mysql_error(); while ($r= mysql_fetch_array($result)) { $hotelid=$r["hotelid"]; $_SESSION['query']=$query; $bgcol='#FFFFFF'; $isBlacklisted=false; if($r['blacklisted']=='Y'){ $bgcol='#999999'; $isBlacklisted=true; } ?> <tr <? if($isBlacklisted){echo "title=\"This hotel is blacklisted. Please only choose it if the client insists on it and you cannot persuade them to use another.\""; } ?>> <td width=88 bgcolor="<? echo $bgcol; ?>"> <a href="cimnetint.php?content=<? echo $source?><? if (isset($clientid)){echo '&clientid='.$clientid;}?>&newhotelid=<? echo $r["hotelid"]?>" target=_parent <? if($isBlacklisted){echo "onClick=\"blackListAlert()\"";} ?>><? echo $r["name"]?></a></td> <td width=90 bgcolor="<? echo $bgcol; ?>"><? echo $r["preferred"]?></a></td> <td width=120 bgcolor="<? echo $bgcol; ?>"><? echo $r["town"]?></td> <td bgcolor="<? echo $bgcol; ?>"><? echo $r["groupname"]?></td> <td align=right bgcolor="<? echo $bgcol; ?>"><? if ($r["rooms"]!='0'){echo $r["rooms"];}?></td> <?php $rq="SELECT rate from venue_rates where ratename like 'Rack%' and hotelid='".$r['hotelid']."' "; $rqs=mysql_query($rq,$conn); $rateval=mysql_result($rqs,0,0); ?> <td bgcolor="<? echo $bgcol; ?>"><? echo $rateval; ?> </td> <td bgcolor="<? echo $bgcol; ?>"></td> </tr> <? }}?> </table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/55937-adding-a-further-behaviour-to-a-page/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.