www.webdeveloper.com
Results 1 to 5 of 5

Thread: Search result problems

  1. #1
    Join Date
    Jun 2006
    Posts
    42

    Arrow Search result problems

    Hey,

    I am redesigning this vacation site and I have run into a little bit of a snag. The problem is, the guy that coded the PHP is from India, and its kind of excessive and difficult to understand what he wants done (its in English obviously, but its a totally different method of coding for me). The problem I have is on http://www.ivrdb.com/searchpage.php?state=AL. I don't want to have to recode the PHP, but I am confused on how else to solve this problem. I query the database and count the items and then using this type of auto-limiter (after so many results it makes another page and so on), it gets screwed up. I think the problem is because after taht query, there is a query for each individual package (its like eBay, except payment packages; the Platinum package owners' listings are at the top with a green background and border and have bold text, the Gold is bold, and Silver is just on the bottom). But I think I need to join the two tables in order to limit the first, and have the subqueries work. Here is my code:

    PHP Code:
    if ($_SESSION['PAGE_NAME'] == "searchpage.php") {
        $query = "SELECT * FROM prop_info WHERE CONTINENTS='North America' AND COUNTRY='United States' AND STATE='$statefull' AND DISPLAY='yes'";
    } else {
        $query = "SELECT * FROM prop_info WHERE CONTINENTS='$con_name' AND COUNTRY='$country_name' $aa AND DISPLAY='yes'";
    }
    $display_limit = '2';
    $items_count = mysql_num_rows(mysql_query($query));
    if(isset($_GET['page_count'])) {
        $page_count = $_GET['page_count'];
    } else {
        if($items_count > $display) {
            $page_count = ceil ($items_count/$display_limit);
        } else {
            $page_count = 1;
        }
    }
    if(isset($_GET['start'])){
        $start = $_GET['start'];
    } else {
        $start = 0;
    }
    $query2 = mysql_query($query . " LIMIT $start,$display_limit");
    $int = 0;
    while ($row = mysql_fetch_array($query2)) {
        $user_array[$int] = $id = $row[0];
        $prop_array[$int] = $prop_id = $row[17];
        $int++;
    }
    $count = count($prop_array);
    $int = 0;
    for ($int_1 = 0; $int_1 < $count; $int_1++) {
        $prop_id = $prop_array[$int_1];
        $id = $user_array[$int_1];
        $query_pay = "SELECT * FROM payment WHERE PROP_ID=$prop_id AND USER_ID=$id AND PAY_STATUS='true' LIMIT $start,$display_limit";
        $result_pay = mysql_query($query_pay);
        $num_pay = 0;
        while ($row_pay = mysql_fetch_array($result_pay)) {
            $stored_start_year = $row_pay[2];
            $stored_start_month = $row_pay[3];
            $stored_start_date = $row_pay[4];
            $stored_end_year = $row_pay[5];
            $stored_end_month = $row_pay[6];
            $stored_end_date = $row_pay[7];
            //Current Days
            $century = mktime(0, 0, 0, 1, 1, 2001);
            $today = time();
            $difference = $today - $century;
            $current_days = floor($difference / 84600);
            //Stored start date
            $today = mktime(12, 0, 0, $stored_start_month, $stored_start_date, $stored_start_year);
            $difference = $today - $century;
            $stored_start_days = floor($difference / 84600);
            //Stored End date
            $today = mktime(12, 0, 0, $stored_end_month, $stored_end_date, $stored_end_year);
            $difference = $today - $century;
            $stored_end_days = floor($difference / 84600);
            if ($current_days <= $stored_end_days && $current_days >= $stored_start_days) {
                $int++;
            }
        }
    }
    if ($int == 0) {
        $c_page = 0;
    } else {
        if (gettype($search_result = $int / $list) == "double") {
            settype($search_result, "integer");
            $search_result = $search_result + 1;
            $c_page = 1;
        }
    }
    if (isset($_REQUEST['c_page'])) {
        $c_page = $_SESSION['C_PAGE'] = $_REQUEST['c_page'];
    } elseif (isset($_SESSION['C_PAGE'])) {
       $c_page = $_SESSION['C_PAGE'];
    } else {
        $_SESSION['C_PAGE'] = $c_page;
    }
    function view_property($list,$c_page,$query) {
    //==============================================================================

            if ($c_page>0)
            { $max = $c_page * $list;
             $min = $max - $list;
            }else{$min = 0;$max = $min + $list;}
            //$query = $_SESSION['SQL_QUERY'];
            $sql_result=mysql_query($query);
            $int = 0; $prop_array=array(); $user_array=array();
            while($row=mysql_fetch_array($sql_result))
                 {
                  $user_array[$int] = $id = $row[0];
                  $prop_array[$int] = $prop_id = $row[17]; $int++;
                 }
           if ($int != 0) {
                   $count = count($prop_array);
           //===========================  Platinum  =================================
           for ($int_1 = 0; $int_1 < $count; $int_1++) {
               $prop_id = $prop_array[$int_1];
               $id = $user_array[$int_1];
               $query_pay = "SELECT * FROM payment WHERE PROP_ID=$prop_id and USER_ID=$id and PAY_STATUS='true' and PURPOSE='Platinum'";
               $result_pay=mysql_query($query_pay);$num_pay = 0;
               while($row_pay=mysql_fetch_array($result_pay)) {
                 $stored_start_year = $row_pay[2];
                 $stored_start_month = $row_pay[3];
                 $stored_start_date = $row_pay[4];
                 $stored_end_year = $row_pay[5];
                 $stored_end_month = $row_pay[6];
                 $stored_end_date = $row_pay[7];
                 //Current Days
                 $century = mktime(0, 0, 0, 1, 1, 2001);
                 $today = time();
                 $difference = $today - $century;
                 $current_days=floor($difference / 84600);
                 //Stored start date
                 $today= mktime(12, 0, 0, $stored_start_month, $stored_start_date, $stored_start_year);
                 $difference = $today - $century;
                 $stored_start_days=floor($difference / 84600);
                 //Stored End date
                 $today = mktime(12, 0, 0, $stored_end_month, $stored_end_date, $stored_end_year);
                 $difference = $today - $century;
                 $stored_end_days=floor($difference / 84600);

                 if ($current_days <= $stored_end_days && $current_days >= $stored_start_days) {
                    $query_2 = "SELECT * FROM prop_info WHERE REGISTRATION_ID=$id and PROP_ID=$prop_id";
                    $result_2=mysql_query($query_2);  $int = 0;
                    while($row=mysql_fetch_array($result_2)){  $int++;
                    $query1 = "SELECT * FROM images_info WHERE REGISTRATION_ID=$id and PROP_ID=$prop_id";
                    $result1=mysql_query($query1); $a = 0;
                    while($row1=mysql_fetch_array($result1)) {
                         $a++;
                         $image_name = $row1[1];
                    }
                    if ($a == 0){$image_name = "imgnotavailable.jpg";}
                    if ($int>$min && $int <= $max) {
                    ?>
                    <tr class="boldrow">
                    <td width="101" class="first">
                    <a href="view_detail_property.php?prop_id=<?php echo $prop_id?>&cp=<? echo $c_page;?>"><img border="0" src="photo/<?php echo $image_name?>" width="100" height="63"></a></td>
                    <td width="111">
                    <p align="center"><font size="2"><?php  echo $row[2]; ?></font></p>
                    <p align="center"><font size="2">
                    <a href="view_detail_property.php?prop_id=<?php echo $prop_id?>&cp=<? echo $c_page;?>">Premium Property Details</a></font></td>
                    <td width="117">
                    <p align="center"><font size="2"><?php  echo $row[1]; ?></font></td>
                    <td>
                    <p align="center"><font size="2"><?php echo $row[9]; ?></font></td>
                    <td>
                    <p align="center"><font size="2"><?php echo $row[10]; ?></font></td>
                    <td>
                    <p align="center"><font size="2"><?php echo $row[11]; ?></font></td>
                    <td width="55">
                    <p align="center"><font size="2"><?php echo $row[5]; ?></font></td>
                    <td width="61" class="last">
                    <p align="center"><font size="2"><?php echo $row[7]; ?></font></td>
                    </tr>
                    <tr>
                    <td width="100%" height="10" colspan="8">&nbsp;</td>
                    </tr>
                    <?php
                   
    }
                   }
                }  }
                }
    There is more, but it is pretty much the same. It is very long, and I may not want to redo it because this project has been a headache already. Any help would be greatly appreciated. Thanks in advance!

  2. #2
    Join Date
    Oct 2005
    Location
    California
    Posts
    603
    I think what you are saying is that the pagination gets messed up, right?

  3. #3
    Join Date
    Jan 2005
    Location
    Alicante (Spain)
    Posts
    7,739

  4. #4
    Join Date
    Jun 2006
    Posts
    42
    Easier said than done. I think its fine for the moment, but I will need to fix it later. For some reason, the last 5 results don't show up. Look: http://www.ivrdb.com/searchpage.php?state=AL

  5. #5
    Join Date
    Oct 2005
    Location
    California
    Posts
    603
    what's $display in if($items_count > $display) ????
    do you mean to say $display_limit isntead of $display?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles