SitePoint Sponsor

User Tag List

Page 3 of 4 FirstFirst 1234 LastLast
Results 51 to 75 of 81
  1. #51
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah I seem to have it sorted.

    I added another bit in to make sure they match up, and it worked, but in my head it didnt seem the natural thing to do, so it suprised me when it worked.

    PHP Code:
    <?
    $r
    =mysql_query("select DISTINCT Id_Rsrt, Nom_Rsrt, IdCntry_Rsrt, Id_show, Act_Hot, IdRsrt_Hot from tbl_resorts, tbl_hotels where (tbl_resorts.IdCntry_Rsrt='1') and (tbl_resorts.Id_show='1') and (tbl_hotels.Act_Hot='1') and (tbl_resorts.Id_Rsrt=tbl_hotels.IdRsrt_Hot) order by Nom_Rsrt 
    ?>
    This bit

    PHP Code:
    <?
    and (tbl_resorts.Id_Rsrt=tbl_hotels.IdRsrt_Hot)
    ?>

  2. #52
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,234
    Mentioned
    154 Post(s)
    Tagged
    0 Thread(s)
    This is a guess, but its probably because you didn't join the tables, you purely asked for information from both tables (try the below).

    Code SQL:
    SELECT 
      DISTINCT Id_Rsrt, 
        Nom_Rsrt,
        IdCntry_Rsrt, 
        Id_show, 
        Act_Hot, 
        IdRsrt_Hot 
    FROM tbl_resorts
      LEFT JOIN tbl_hotels ON (tbl_resorts.Id_Rsrt=tbl_hotels.IdRsrt_Hot)
    WHERE (tbl_resorts.IdCntry_Rsrt='1') 
      AND (tbl_resorts.Id_show='1') 
      AND (tbl_hotels.Act_Hot='1') 
    ORDER BY Nom_Rsrt

  3. #53
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes that worked, and its a new way that I havent come across before...

    Thanks.

  4. #54
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    MMMM, major problem now.

    All was good until I added the countries in to allow the user to flick through the countries, and its fine, as I can get the ID from the country to make sure the regions are showing correctly for the country.

    But then its when I select a region which are pushed into an array and I cant add the country back into the url to keep the user on the same country until they select another.

    http://devchecksafetyfirst.csf.dcman...php?Country=65

    When I select a country i can easily pass the id through, but I cant work out when i select a region how to pass the country id through with it so I can pick it up by using GET and assigning it to a variable.

    Have I gone and snookered myself?

    Code:
    <?
    session_start();
    error_reporting(E_ALL);
    ini_set('display_errors','Off');
    include("config.php");
    
    $selectCountry=@$_GET['Country'];
    
    // Regions array
    if (is_array($_GET['regions'])) {
    	 $regionsArray = array();
         foreach($_GET['regions'] as $regions) {	 
    	 $regionsArray[] = '\''.$regions.'\'';
         }
    	 
    	 $regionData = implode(',', $regionsArray);	 
    	 $sqlregion =  'AND IdRsrt_Hot IN ('. $regionData .' )';
    	 $sqlregionName =  'WHERE Id_Rsrt IN ('. $regionData .' )';
    	 
    	 //echo $sqlregionName; 
    	 //echo $regionData;
    	 //echo $sqlregion;
    }
    
    // Star rating array
    if (is_array($_GET['star'])) {
    	 $starArray = array();
         foreach($_GET['star'] as $star) {
    	 $starArray[] = '\''.$star.'\'';
         }
    	 $starData = implode(',', $starArray);
    	 $sqlstar =  'AND IdCat_Hot IN ('. $starData .' )';	 
    	 //echo $regionData;
    	 //echo $sqlstar;
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>CSF Result Page</title>
    <link href="css/style.css" rel="stylesheet" type= "text/css" />
    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    </head>
    <body>
    <div id="wrapper">
    <div id="header">
    <p style="position:relative; padding:10px;">All countries below:</p>
    <? $d=mysql_query("select * from tbl_countries order by Nom_Cntry ASC");  
    while($f=mysql_fetch_assoc($d)){ ?> 
    '<a href="index.php?Country=<?=$f['Id_Cntry']?>"><?=$f['Nom_Cntry']?></a>',
    <? } ?>
    </div>
    
    <div id="result_Center_Block">
    
    <!-- Start of Breadcrumb
    <div style="position:relative; width:100%; height:30px; text-align:left; padding-left:12px; padding-top:5px; padding-bottom:20px;">
    <p><strong>Showing results for:</strong> 
    <? if ($sqlstar=="") { ?>
    
    <? } else { ?>
    <?=$starData?> star hotels in 
    <? } ?>
    <? if ($sqlregion=="") { ?>
    Tunisia
    <? } else { ?>
    <? $q=mysql_query("select Id_Rsrt, Nom_Rsrt from tbl_resorts " . $sqlregionName . "");  
    while($n=mysql_fetch_assoc($q)){ ?> 
    '<?=$n['Nom_Rsrt']?>',
    <? } ?>
    TUNISIA
    <? } ?>
    </p>
    </div>End of breadcrumb -->
    
    <div id="result_Left_Nav_Bar">
    <form name="form1" id="myForm"> 
    <!-- Regions -->
    <p><strong>Regions:</strong></p>
    <?php   
    $r=mysql_query("SELECT DISTINCT Id_Rsrt, Nom_Rsrt, IdCntry_Rsrt, Id_show, Act_Hot, IdRsrt_Hot FROM tbl_resorts LEFT JOIN tbl_hotels ON (tbl_resorts.Id_Rsrt=tbl_hotels.IdRsrt_Hot) WHERE (tbl_resorts.IdCntry_Rsrt='".$selectCountry."') AND (tbl_resorts.Id_show='1') AND (tbl_hotels.Act_Hot='1') ORDER BY Nom_Rsrt");  
    while($q=mysql_fetch_assoc($r)){ ?> 
    <input type="checkbox" name="regions[]" value="<?=$q['Id_Rsrt']?>" onClick="javascript:checkRefresh()" <?=((in_array($q['Id_Rsrt'], $_REQUEST['regions'])) ? "checked=\"checked\" " : "")?> class="inline" /><?=$q['Nom_Rsrt']?></a>&nbsp;<?
    $queryNumber = mysql_query("select count(Id_Hot) as total from tbl_hotels where (IdRsrt_Hot='". $q['Id_Rsrt'] ."') and (Act_Hot='1')");
    $resultNumber = mysql_fetch_array($queryNumber); ?>
    <span style="font-size:12px; color:#900; vertical-align:1px;">[<? echo $resultNumber['total'];?>]</span>
    <br/>
    <? } ?> 
    <!-- End Regions -->
    <br/>
    <p><strong>Star Rating:</strong></p>
    <!-- Star Rating -->
    <?php
    if ($sqlregion==""){
    $s=mysql_query("select DISTINCT IdCat_Hot from tbl_hotels WHERE IdCat_Hot IN (1,2,3,4,5) and (Act_Hot='1') order by IdCat_Hot ASC");  
    while($b=mysql_fetch_assoc($s)){ ?>
    <input type="checkbox" name="star[]" value="<?=$b['IdCat_Hot']?>" onClick="javascript:checkRefresh()" <?=((in_array($b['IdCat_Hot'], $_REQUEST['star'])) ? "checked=\"checked\" " : "")?> class="inline" /> <?=$b['IdCat_Hot']?> Star<br/>
    <? } ?>	
    <? } else {
    $s=mysql_query("select DISTINCT IdCat_Hot from tbl_hotels WHERE IdRsrt_Hot IN (". $regionData .") and (Act_Hot='1') order by IdCat_Hot ASC");  
    while($b=mysql_fetch_assoc($s)){ ?> 
    <input type="checkbox" name="star[]" value="<?=$b['IdCat_Hot']?>" onClick="javascript:checkRefresh()" <?=((in_array($b['IdCat_Hot'], $_REQUEST['star'])) ? "checked=\"checked\" " : "")?> class="inline" /> <?=$b['IdCat_Hot']?> Star<br/>
    	<? } ?>
    <? } ?> 
    <!-- End Star rating --> 
    
    </form>
    </div>
    <div id="result_Right_Results">
    
    <?
    // Build result query on values of the array
    $sql.="select * from tbl_hotels where Act_Hot='1' ";
    	if ($sqlregion==""){
    	$sql.= " and IdCntry_Hot='".$selectCountry."'";
    	} else {
    	$sql.= "" .$sqlregion . "";  
    	}
    	if ($sqlstar==""){
    	$sql.= " and IdCat_Hot IN (1,2,3,4,5,6)";
    	} else {
    	$sql.= "" .$sqlstar . "";  
    	}
    $sql.= " order by Id_Hot ASC"; 
    $result = mysql_query($sql);
    while($q=mysql_fetch_assoc($result)){  
    ?>
    <div class="result_Hotel">
    <p style="position:relative; margin:10px;"><?=$q['Nom_Hot']?></p>
    </div>
    <? }
    // End Build query	
    ?>
    
    </div>
    </div>
    <div style="position:relative; width:100%; height:2px; clear:both"></div>
    </div>
    <?php require_once('footer.php'); ?>
    
    <!-- Black Overlay Script -->
    <script type="text/javascript">
          jQuery.fn.center = function () {
            this.css("position","absolute");
            this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
            this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
            return this;
          }  
    
          $(document).ready(function() {
            $("input:checkbox").on("change", function(e) {
    		document.form1.submit();
              $("#result").hide();
              //var v = ($(this).val());
              
              $('<div id="black_overlay"></div>').appendTo('body');
              $('<div id="loading">Loading Content</div>').appendTo('body').center();
              
              $.ajax({
                //type : "POST",
                //url : "sleep.php",
               // data  : 'v=' + v,
                success : function(res) {
                  $("#loading").remove();
    			 
                  $('#black_overlay').fadeOut('slow', function() {
                    $('#black_overlay').remove();
                   // $("#result").text("You chose option " + res).css("display", "inline-block");
                  });
    			             
                }
              });
            });
          });
    </script>
    <!-- End Black Overlay Script -->
    </body>
    </html>

  5. #55
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,234
    Mentioned
    154 Post(s)
    Tagged
    0 Thread(s)
    Where is your code for building the URL?

  6. #56
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the problem as far as I can see, there isnt any, but what happens by the looks is that when a checkbox is selected it call this function in the javascript at the bottom of the page, which includes the document.form1.submit()

    Code:
    $(document).ready(function() {
            $("input:checkbox").on("change", function(e) {
    		document.form1.submit();
    Then when I look in the url it shows the id of the region i selected and where I need also to add the current country selection, so when I select a country it looks like this:

    http://devchecksafetyfirst.csf.dcman...php?Country=57

    Then when i select a region within that country the url becomes:

    http://devchecksafetyfirst.csf.dcman...ions%5B%5D=289

  7. #57
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,234
    Mentioned
    154 Post(s)
    Tagged
    0 Thread(s)
    Added Country as a hidden field to your form.

    PHP Code:
    <?php if (isset($_GET['Country'])) { ?>
     <input type="hidden" name="Country" value="<?=$_GET['Country'];?>" />
    <?php ?>
    Eventually, you may need to make this even smarter so it just adds all get variables as hidden fields (something like so)
    PHP Code:
    <?php foreach ($_GET as $key => $val) { ?>
     <input type="hidden" name="<?=$key;?>" value="<?=$val;?>" />
    <?php ?>

  8. #58
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah right, I see.

    I understand the first example, but not sure at all about the second one.

    Is it a way of joining the hidden fields up one go, is that it?

  9. #59
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,234
    Mentioned
    154 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by multichild View Post
    Is it a way of joining the hidden fields up one go, is that it?
    Yes, however, keep in mind that it will take everything sent via GET and write it as a hidden field (it may still need some work too). So if you have a clever user, they could inject their own form hidden fields by passing them in the URL.

  10. #60
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm using the code below that you posted a little while ago, but rather than connecting two tables, how would it work if I needed to connect to 3 tables.

    PHP Code:
    <?
    $r
    =mysql_query("SELECT DISTINCT Id_Tem, Id_Hot, Id_Tem, Id_Hot, IdCntry_Hot, IdRsrt_Hot, Act_Hot FROM tbl_tematics LEFT JOIN tbl_hotels ON (tbl_resorts.Id_Rsrt=tbl_hotels.IdRsrt_Hot) WHERE (tbl_resorts.IdCntry_Rsrt='".$selectCountry."') AND (tbl_resorts.Id_show='1') AND (tbl_hotels.Act_Hot='1') ORDER BY Nom_Rsrt");
    ?>

  11. #61
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,234
    Mentioned
    154 Post(s)
    Tagged
    0 Thread(s)
    What is the name of the third table and what columns does it have that are related to either tbl_tematics or tbl_hotels?

  12. #62
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well this is how it looks, and in honesty im a little worried as there are same name columns, but this is how it works.

    This database was put together a long time ago for a different format website, but they dont want to change it at this point as there time constraints.

    tbl_tematics - Id_Tem

    thats is the start

    then that relates to this tabel

    tbl_hotntem - Id_Hot & Id_Tem

    which then relates to content in the final table

    tbl_hotels - Id_Hot, IdCntry_Hot, Act_Hot

  13. #63
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,234
    Mentioned
    154 Post(s)
    Tagged
    0 Thread(s)
    Okay, so it looks like you could do this:

    Code SQL:
    SELECT 
      DISTINCT Id_Tem
        , Id_Hot, Id_Tem
        , Id_Hot
        , IdCntry_Hot
        , IdRsrt_Hot
        , Act_Hot 
    FROM tbl_tematics 
      LEFT JOIN tbl_hotntem ON (tbl_resorts.Id_Tem=tbl_hotntem.Id_Tem)
      LEFT JOIN tbl_hotels ON (tbl_resorts.Id_Rsrt=tbl_hotels.IdRsrt_Hot)
    WHERE 
      (tbl_resorts.IdCntry_Rsrt='".$selectCountry."') 
      AND (tbl_resorts.Id_show='1') 
      AND (tbl_hotels.Act_Hot='1') 
    ORDER BY Nom_Rsrt

    You may need to tweak the query (the ON statement specifically to make sure it matches on the appropriate columns)

  14. #64
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh so its ok to have the same column names when doing a search using more than one table.

    Oh thats not so bad then and thanks cpradio that looks just the ticket, will give it a go and see, and yes can see the tweeks to get it right.

    Thanks mate

    Its coming together nicely in honesty and Im very happy that I'm getting through the bulk of it myself, which wasnt the case ont he last project, so there def progress over the year, so thank you for that again.

  15. #65
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is I think how it needs to work for me:

    PHP Code:
    <?
    $x
    =mysql_query("SELECT DISTINCT Id_Tem, Desc_Tem, Id_Hot, Id_Tem, Id_Hot, IdCntry_Hot, IdRsrt_Hot, Act_Hot FROM tbl_tematics 
      LEFT JOIN tbl_hotntem ON (tbl_tematics.Id_Tem=tbl_hotntem.Id_Tem)
      LEFT JOIN tbl_hotels ON (tbl_hotntem.Id_Hot=tbl_hotels.Id_Hot)
    WHERE 
      (tbl_hotels.IdCntry_Hot='"
    .$selectCountry."') 
      AND (tbl_hotels.Act_Hot='1') 
    ORDER BY Desc_Tem"
    );  
    while(
    $z=mysql_fetch_assoc($x)){ ?> 
    <input type="checkbox" name="category[]" value="<?=$z['tbl_tematics.Id_Tem']?>" onClick="javascript:checkRefresh()" <?=((in_array($z['tbl_tematics.Id_Tem'], $_REQUEST['category'])) ? "checked=\"checked\" " "")?> class="inline" /> <?=$z['tbl_tematics.Desc_Tem']?><br/>
    And here is the relationships and tabels.

    tbl_tematics = Id_Tem, Desc_Tem
    tbl_hotntem = Id_Hot, Id_Tem
    tbl_hotels = Id_Hot, IdCntry_Hot, Act_Hot

    Why I'm posting back is because I'm not getting the output on the page for categories

  16. #66
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,234
    Mentioned
    154 Post(s)
    Tagged
    0 Thread(s)
    I suggest running your query in phpMyAdmin and see what you get back. You may be getting an error, in fact, I'm almost certain you are.

    What I see is this:
    Code:
    SELECT DISTINCT Id_Tem, Desc_Tem, Id_Hot, Id_Tem, Id_Hot, IdCntry_Hot, IdRsrt_Hot, Act_Hot
    Place the tablename in front of each column.

    Code:
    SELECT DISTINCT tbl_tematics.Id_Tem, tbl_tematics.Desc_Tem, tbl_tematics.Id_Hot, tbl_tematics.Id_Tem, tbl_hotels.IdCntry_Hot, tbl_hotels.IdRsrt_Hot, tbl_hotels.Act_Hot

  17. #67
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no sorry its wrong, 2 secs, i thnk i can see the problem, its the final Id_Hot.

    The others are created this one is the auto increment.

  18. #68
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No again, I think its right.

    Ok lets work it through as you have done.

  19. #69
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok I is giving an output now using the code below, but its not outputting the name and it isnt being DISTINCT with its out put either:

    PHP Code:
    <?
    $x
    =mysql_query("SELECT DISTINCT tbl_tematics.Id_Tem, tbl_tematics.Desc_Tem, tbl_hotntem.Id_Hot, tbl_hotntem.Id_Tem, tbl_hotels.Id_Hot, tbl_hotels.IdCntry_Hot, tbl_hotels.IdRsrt_Hot, tbl_hotels.Act_Hot
    FROM tbl_tematics
    LEFT JOIN tbl_hotntem ON ( tbl_tematics.Id_Tem = tbl_hotntem.Id_Tem ) 
    LEFT JOIN tbl_hotels ON ( tbl_hotntem.Id_Hot = tbl_hotels.Id_Hot ) 
    WHERE (
    tbl_hotels.IdCntry_Hot ='1'
    )
    AND (
    tbl_hotels.Act_Hot ='1'
    )
    ORDER BY tbl_tematics.Desc_Tem"
    );  
    while(
    $z=mysql_fetch_assoc($x)){ ?> 
    <input type="checkbox" name="category[]" value="<?=$z['tbl_tematics.Id_Tem']?>" onClick="javascript:checkRefresh()" <?=((in_array($z['tbl_tematics.Id_Tem'], $_REQUEST['category'])) ? "checked=\"checked\" " "")?> class="inline" /> <?=$z['tbl_tematics.Desc_Tem']?><br/>
    <? ?>

  20. #70
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,234
    Mentioned
    154 Post(s)
    Tagged
    0 Thread(s)
    You'd have to play with that query in phpMyAdmin until you get it to output what you want. Unfortunately, I'd have to have the schemas, and data to be able to assist with that.

  21. #71
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ye I dont think its going to happen this way as the DISTINCT is working correctly, its just that I think its bringing out the DISTINCT hotels, when all i want is to bring out one DISTINCT category title thats contained within the country, if it does occur.

    i thikn i need to use DISTINCT again somewhere, to only show one, so I suppose a query within a query

  22. #72
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm having trouble getting the right data out for a count with the code below, its not right, so wondered if you can remind me how to see what is it the code below is doing.

    PHP Code:
    <?
    $queryNumber 
    mysql_query("select count(Id_Hot) as total from tbl_hotntem LEFT JOIN tbl_hotels ON (tbl_hotels.Id_Hot=tbl_hotntem.Id_Hot) where (IdRsrt_Hot='"$q['Id_Rsrt'] ."') and (tbl_hotntem.Id_Tem IN ("$categoryData ."))");
    ?>

  23. #73
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,234
    Mentioned
    154 Post(s)
    Tagged
    0 Thread(s)
    Well if you want to see what it is sending to MySQL, just put this line above or below your line:

    PHP Code:
    echo "select count(Id_Hot) as total from tbl_hotntem LEFT JOIN tbl_hotels ON (tbl_hotels.Id_Hot=tbl_hotntem.Id_Hot) where (IdRsrt_Hot='"$q['Id_Rsrt'] ."') and (tbl_hotntem.Id_Tem IN ("$categoryData ."))"
    That should show you the query being executed, copy and paste that into phpMyAdmin (or whatever tool you use) and see what results it gives you.

  24. #74
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    915
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi cpradio,

    Can you see what is wrong with the line of code below.

    PHP Code:
    <?
    $sql
    .="select * FROM tbl_hotels ". if ($sqlcategory=="") { } else { $sqlcategory; } ." WHERE Act_Hot='1' ";
    ?>
    An error keeps coming up in Dreamweaver to say its not right.

  25. #75
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,234
    Mentioned
    154 Post(s)
    Tagged
    0 Thread(s)
    Yep, that is not valid syntax.

    You mean to do any of the following:
    PHP Code:
    <? 
    $sql
    .="select * FROM tbl_hotels ".  ((!empty($sqlcategory)) ? $sqlcategory "") ." WHERE Act_Hot='1' "
    ?>
    PHP Code:
    <? 
    if (!empty($sqlcategory))
      
    $sql.="select * FROM tbl_hotels "$sqlcategory ." WHERE Act_Hot='1' "
    else
      
    $sql.="select * FROM tbl_hotels WHERE Act_Hot='1' "
    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •