SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict
    Join Date
    Jan 2006
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cols and rows plz help, I am so stuck.

    I am working on a script and having some major issues with some of the code. I have been stuck at this one point for 4 days now and I have been working on and trying to figure out how to code this one page for 10-12 hours a day for the last 4 days. I have had no luck and was hoping someone can help me figure this one out.

    The site name is Florida Fine Cars.

    How the site works. It is a listing website site for the all the sales people at the car dealership I work for. Each sales person can sign in and upload photos of thier monthy cars. Each sales person can choose a sub category, under the main category(main category is view all cars, sub cats are all the car manufactuers...such as honda ...acura.) No matter who the sales person is or what sub cat they list thier car in the pictures are stored in one folder(one images folder for all pics and cat and subcats). Also no matter what sub category the sales people list the car it it will also show up in view all cars (the main category). Also the sales people can upload 10 pictures of each car.

    The problem which I need help with is when you click on either of them the main category(view all cars) or the subcategories(acura...honda...ford...chevy) the actual script for when you click on them is search.php that is where I am having the problem. The search results displays the first thumbnail image and a short description on the right, then the next listing in that sub category is listed under it, when you click on the tumbnail it then goes in the actual listing with the full description and other 9 images. I am trying for the last 4 days over 10 hours a day to change the script so that instead of the results for the cat and subcat's being displayed as they now are one under the other with script on the side of the image...to be displayed in cols and rows... with no script on the right of the pic. just the main image (thumbnail) of the car with the year & model(such as 05 accord) under the image.

    I have included a screenshot of the site with the search results when you click on a sub cat, and the script below. I will appreciate any help anyone can give me so I can accomplish this. Thank you everyone.,

    Click here for picture of the current search results...

    Click here to see a picture of what I am trying to achieve.


    This is the searchtemplate.php
    PHP Code:
    <?=$ListingTable?>
    This is the search.php script which I need help with....
    PHP Code:
    require_once("conn.php");
    require_once(
    "includes.php");

    $query = array();

    if(!empty(
    $_GET[c]))
    {
            
    $query[] = "re2_listings.CategoryID = '$_GET[c]' ";
    }

    if(!empty(
    $_GET[s]))
    {
            
    $query[] = "re2_listings.SubcategoryID = '$_GET[s]' ";
    }

    if(!empty(
    $_GET[search_state]))
    {
            
    $query[] = "re2_listings.state = '$_GET[search_state]' ";
    }

    if(!empty(
    $_GET[search_city]))
    {
            
    $query[] = "re2_listings.city = '$_GET[search_city]' ";
    }


    if(!empty(
    $query))
    {
            
    $MyQuery implode(" and "$query);

            
    $MyQuery "and ".$MyQuery;
    }


    ////////////////////////////////////////////////////////////
    //////////                order by

    $order = array();

    if(!empty(
    $_GET[orderby]))
    {
            
    $MyOrder explode("|"$_GET[orderby]);

            while(list(,
    $ov) = each($MyOrder))
            {
                    if(
    $ov == "DateAdded")
                    {
                            
    $order[] = " re2_listings.DateAdded desc ";
                    }
                    
                    if(
    $ov == "Price")
                    {
                            
    $order[] = " re2_listings.Price asc ";
                    }
                    
                    if(
    $ov == "address")
                    {
                            
    $order[] = " re2_listings.address asc ";
                    }

            }
    }
    else
    {
            if(!empty(
    $_GET[p]))
            {
                    
    $order[] = " re2_listings.Price asc ";
            }

            if(!empty(
    $_GET[r]))
            {
                    
    $order[] = " re2_listings.rooms asc, re2_listings.bathrooms asc, re2_listings.garage asc ";
            }

            if(!empty(
    $_GET[city]))
            {
                    
    $order[] = " re2_listings.city, re2_listings.address, re2_listings.state ";
            }

    }


    if(
    count($order) > '0')
    {
            
    $MyOrder implode(", "$order);

    }

    if(empty(
    $MyOrder))
    {
            
    $MyOrder " order by re2_agents.PriorityLevel desc, re2_listings.DateAdded desc";
    }
    else
    {
            
    $MyOrder " order by re2_agents.PriorityLevel desc, $MyOrder";
    }


    if(!empty(
    $_GET[Start]))
    {
            
    $Start $_GET[Start];
    }
    else
    {
            
    $Start '0';
    }

    $ByPage '20';

    $q1 "select * from re2_listings, re2_agents, re2_priority where re2_listings.AgentID = re2_agents.AgentID and re2_agents.PriorityLevel = re2_priority.PriorityLevel and re2_agents.AccountStatus = 'active' $MyQuery $MyOrder limit $Start$ByPage ";

    $qnav "select * from re2_listings, re2_agents where re2_listings.AgentID = re2_agents.AgentID $MyQuery";

    $r1 mysql_query($q1) or die(mysql_error());
    $lrows mysql_num_rows($r1);

    if(
    $lrows '0')
    {
            
    $ListingTable .= "<table align=center width=510 border=1 bordercolor=black frame=hsides rules=rows cellspacing=0>\n";

            while(
    $a1 mysql_fetch_array($r1))
            {
                    
    $ListingTable .= "<tr onMouseOver=\"this.style.background='#E2E2E2'; this.style.cursor='hand'\" onMouseOut=\"this.style.background='white'\" onClick=\"window.open('info.php?id=$a1[ListingID]', '_top')\">\n\t";
                    
                    if(
    $a1[PriorityLevel] > '1')
                    {
                            
    $sub "<span class=RedLink><sup>$a1[PriorityName]</sup></span>";
                    }

                    
    $ListingTable .= "\n\t<td width=15>";

                    if(!empty(
    $a1[image]))
                    {
                            
    $im_array explode("|"$a1[image]);
                            
    $ListingTable .= "<img src=\"re_images/$im_array[0]\" width=125 height=93>";
                    }

                    
    $ListingTable .= "</td>\n\t";


                    
    $ListingTable .= "<td width=250>$a1[city]  $a1[state]  $a1[address] $sub</td>\n\t";
                    
    $ListingTable .= "<td width=250>$a1[rooms] miles $a1[country] Transmission";

                    
    $MyPrice number_format($a1[Price], 2"."",");

                    
    $ListingTable .= "</td>\n\t<td align=center width=100><b>$$MyPrice</td>\n";
                    
    $ListingTable .= "</tr>\n";

            }

            
    $ListingTable .= "</table>";

                    
    $rnav mysql_query($qnav) or die(mysql_error());
                    
    $rows mysql_num_rows($rnav);

                            if(
    $rows $ByPage)
                            {
                                    
    $ListingTable .=  "<br><table align=center width=510>";
                                    
    $ListingTable .= "<td align=center><font face=verdana size=2> | ";

                                    
    $pages ceil($rows/$ByPage);

                                    for(
    $i 0$i <= ($pages); $i++)
                                    {
                                            
    $PageStart $ByPage*$i;
            
                                            
    $i2 $i 1;
            
                                            if(
    $PageStart == $Start)
                                            {
                                                    
    $links[] = " <span class=RedLink>$i2</span>\n\t ";
                                            }
                                            elseif(
    $PageStart $rows)
                                            {
                                                    
    $links[] = " <a class=BlackLink href=\"search.php?Start=$PageStart&c=$_GET[c]&s=$_GET[s]&AgentID=$_GET[AgentID]&search_city=$_GET[search_city]&search_state=$_GET[search_state]&city=$_GET[city]&p=$_GET[p]&r=$_GET[r]\">$i2</a>\n\t ";
                                            }
                                    }

                                    
    $links2 implode(" | "$links);
                    
                                    
    $ListingTable .= $links2;

                                    
    $ListingTable .= "| </td>";

                                    
    $ListingTable .= "</table><br>\n";

                            }
    }
    else
    {
            
    $ListingTable "<br><br><center>No results were found!</center>";
    }

    require_once(
    "templates/HeaderTemplate.php");
    require_once(
    "templates/SearchTemplate.php");        
    require_once(
    "templates/FooterTemplate.php"); 

  2. #2
    SitePoint Addict
    Join Date
    Jan 2006
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please if anyone knows how I can script this so I can get rows and columns of pics please give me some direction as to how I can do this. I am totally lost.

  3. #3
    SitePoint Addict
    Join Date
    Jan 2006
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If anyone is up for $100.00 it is now this is now listed in the Contest Forum..

  4. #4
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am afraid I dont really get it. Are the cols suppose to have identical pictures? I assume it is a mock up. If the pics are diffrent, is each col and each frame a different car?

  5. #5
    SitePoint Addict
    Join Date
    Jan 2006
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mkdrums
    I am afraid I dont really get it. Are the cols suppose to have identical pictures? I assume it is a mock up. If the pics are diffrent, is each col and each frame a different car?
    all the pics should be different. They should be the main picture for all the car listings in each sub-category. I just altered the image in photoshop to show how I wanted the columns and rows instead of the search results are in the first pic. The first pic is a screen shot of how the listing of each sub cat comes up with the way the script is now. Second pic is what I am trying to achieve with the rows and columns. So please note all the pictures should not be the same. They should actually be the first or main image of each listing the sub cats.

  6. #6
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm...just did something like this on an ecommerce site I'm building.

    I tried a table for this at first, but since the site has a liquid layout and I wanted the number of columns to increase with the browser width, I went with a definition list. This has worked much better.

    Hope that helps some...I'm not on my regular system at the moment, but I'll post the code when I get back.

    Added: OK, this is pretty close to what I have in the app, but I can't remember exactly how I styled the dt / dd combination, so this uses a single dd with a span to wrap the info below the image...kinda cheesy, but it works.

    HTML example:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Furniture</title>
    
    <!-- META TAGS  //-->
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Language" content="en-us">
    
    <!-- STYLESHEETS //-->
    <style type="text/css">
    * {margin:0;padding:0}
    html,body {height:100%;}
    body {font:100.01%/110% Arial,Helvetica,sans-serif;background-color:#FFF;}
    dl.i_lst dd {float:left;display:inline;position:relative;list-style:none;}
    dl.i_lst dd span {clear:left;font-size:0.86em;text-align:center;text-transform:uppercase;display:block;}
    dl.i_lst dd img {width:150px;height:112px;}
    </style>
    </head>
    
    <body>
    <dl class="i_lst">
    <dd>
    <a href="#"><img src="/photos/DPD-300BKL-1.jpg" width="150" height="112" alt="Sectional D-300"></a>
    <span><a href="#">Item D-300</a></span>
    </dd>
    
    <dd>
    <a href="#"><img src="/photos/DPD-300BKL-2.jpg" width="150" height="112" alt="Sectional D-301"></a>
    <span><a href="#">Item D-301</a></span>
    </dd>
    
    <dd>
    <a href="#"><img src="/photos/DPD-300BKL-3.jpg" width="150" height="112" alt="Sectional D-302"></a>
    <span><a href="#">Item D-302</a></span>
    </dd>
    
    <dd>
    <a href="#"><img src="/photos/DPD-300BKL-4.jpg" width="150" height="112" alt="Sectional D-303"></a>
    <span><a href="#">Item D-303</a></span>
    </dd>
    
    <dd>
    <a href="#"><img src="/photos/DPD-300BKL-5.jpg" width="150" height="112" alt="Sectional D-304"></a>
    <span><a href="#">Item D-304</a></span>
    </dd>
    
    <dd>
    <a href="#"><img src="/photos/DPD-300BKL-6.jpg" width="150" height="112" alt="Sectional D-305"></a>
    <span><a href="#">Item D-305</a></span>
    </dd>
    
    <dd>
    <a href="#"><img src="/photos/DPD-300BKL-7.jpg" width="150" height="112" alt="Sectional D-306"></a>
    <span><a href="#">Item D-306</a></span>
    </dd>
    
    <dd>
    <a href="#"><img src="/photos/DPD-300BKL-8.jpg" width="150" height="112" alt="Sectional D-307"></a>
    <span><a href="#">Item D-307</a></span>
    </dd>
    </dl>
    </body>
    </html>
    I believe your code should be something like this (assumes external stylesheet with entries in above example):

    Code:
    require_once("conn.php");
    require_once("includes.php");
    
    $query = array();
    
    if(!empty($_GET[c]))
    {
            $query[] = "re2_listings.CategoryID = '$_GET[c]' ";
    }
    
    if(!empty($_GET[s]))
    {
            $query[] = "re2_listings.SubcategoryID = '$_GET[s]' ";
    }
    
    if(!empty($_GET[search_state]))
    {
            $query[] = "re2_listings.state = '$_GET[search_state]' ";
    }
    
    if(!empty($_GET[search_city]))
    {
            $query[] = "re2_listings.city = '$_GET[search_city]' ";
    }
    
    
    if(!empty($query))
    {
            $MyQuery = implode(" and ", $query);
    
            $MyQuery = "and ".$MyQuery;
    }
    
    
    ////////////////////////////////////////////////////////////
    //////////                order by
    
    $order = array();
    
    if(!empty($_GET[orderby]))
    {
            $MyOrder = explode("|", $_GET[orderby]);
    
            while(list(,$ov) = each($MyOrder))
            {
                    if($ov == "DateAdded")
                    {
                            $order[] = " re2_listings.DateAdded desc ";
                    }
                    
                    if($ov == "Price")
                    {
                            $order[] = " re2_listings.Price asc ";
                    }
                    
                    if($ov == "address")
                    {
                            $order[] = " re2_listings.address asc ";
                    }
    
            }
    }
    else
    {
            if(!empty($_GET[p]))
            {
                    $order[] = " re2_listings.Price asc ";
            }
    
            if(!empty($_GET[r]))
            {
                    $order[] = " re2_listings.rooms asc, re2_listings.bathrooms asc, re2_listings.garage asc ";
            }
    
            if(!empty($_GET[city]))
            {
                    $order[] = " re2_listings.city, re2_listings.address, re2_listings.state ";
            }
    
    }
    
    
    if(count($order) > '0')
    {
            $MyOrder = implode(", ", $order);
    
    }
    
    if(empty($MyOrder))
    {
            $MyOrder = " order by re2_agents.PriorityLevel desc, re2_listings.DateAdded desc";
    }
    else
    {
            $MyOrder = " order by re2_agents.PriorityLevel desc, $MyOrder";
    }
    
    
    if(!empty($_GET[Start]))
    {
            $Start = $_GET[Start];
    }
    else
    {
            $Start = '0';
    }
    
    $ByPage = '20';
    
    $q1 = "select * from re2_listings, re2_agents, re2_priority where re2_listings.AgentID = re2_agents.AgentID and re2_agents.PriorityLevel = re2_priority.PriorityLevel and re2_agents.AccountStatus = 'active' $MyQuery $MyOrder limit $Start, $ByPage ";
    
    $qnav = "select * from re2_listings, re2_agents where re2_listings.AgentID = re2_agents.AgentID $MyQuery";
    
    $r1 = mysql_query($q1) or die(mysql_error());
    $lrows = mysql_num_rows($r1);
    
    if($lrows > '0')
    {
            $ListingTable .= "<dl class=\"i_lst\">\n";
    
            while($a1 = mysql_fetch_array($r1))
            {                
                    if($a1[PriorityLevel] > '1')
                    {
                            $sub = "<span class=RedLink><sup>$a1[PriorityName]</sup></span>";
                    }
    
                    if(!empty($a1[image]))
                    {
                            $im_array = explode("|", $a1[image]);
                            $ListingTable .= "<dd><a href=\"window.open('info.php?id=$a1[ListingID]', '_top')\"><img src=\"re_images/$im_array[0]\" width=\"125\" height=\"93\"></a>";
                    }
    								
    								// Guessing you have something like make or model name as a field
    
                    $ListingTable .= "<span><a href=\"window.open('info.php?id=$a1[ListingID]', '_top')\">$a1[make]  $a1[model]</span></a></dd>"\n\t";
    
            }
    
            $ListingTable .= "</dl>";
    
                    $rnav = mysql_query($qnav) or die(mysql_error());
                    $rows = mysql_num_rows($rnav);
    
                            if($rows > $ByPage)
                            {
                                    $ListingTable .=  "<br><table align=center width=510>";
                                    $ListingTable .= "<td align=center><font face=verdana size=2> | ";
    
                                    $pages = ceil($rows/$ByPage);
    
                                    for($i = 0; $i <= ($pages); $i++)
                                    {
                                            $PageStart = $ByPage*$i;
            
                                            $i2 = $i + 1;
            
                                            if($PageStart == $Start)
                                            {
                                                    $links[] = " <span class=RedLink>$i2</span>\n\t ";
                                            }
                                            elseif($PageStart < $rows)
                                            {
                                                    $links[] = " <a class=BlackLink href=\"search.php?Start=$PageStart&c=$_GET[c]&s=$_GET[s]&AgentID=$_GET[AgentID]&search_city=$_GET[search_city]&search_state=$_GET[search_state]&city=$_GET[city]&p=$_GET[p]&r=$_GET[r]\">$i2</a>\n\t ";
                                            }
                                    }
    
                                    $links2 = implode(" | ", $links);
                    
                                    $ListingTable .= $links2;
    
                                    $ListingTable .= "| </td>";
    
                                    $ListingTable .= "</table><br>\n";
    
                            }
    }
    else
    {
            $ListingTable = "<br><br><center>No results were found!</center>";
    }
    
    require_once("templates/HeaderTemplate.php");
    require_once("templates/SearchTemplate.php");        
    require_once("templates/FooterTemplate.php");
    Good luck, and let me know if it works out for you!

    TaliaJ
    Last edited by TaliaJ; May 6, 2006 at 19:17. Reason: Added Code Example

  7. #7
    SitePoint Addict
    Join Date
    Jan 2006
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TaliaJ
    Hmm...just did something like this on an ecommerce site I'm building.

    I tried a table for this at first, but since the site has a liquid layout and I wanted the number of columns to increase with the browser width, I went with a definition list. This has worked much better.

    First, I write out the items in the dl structure (dt for the pic, dd for the caption). The list is styled display:inline, float:left, etc. The results look pretty much like your picture...except it's furniture, not cars.

    Hope that helps some...I'm not on my regular system at the moment, but I'll post the code when I get back.

    TaliaJ
    Thank you very much. The important thing is the code has to function in conjunction with the rest of the code on the site. This thread is on the contest forum in this website. I am paying $100.00 for the first person that can produce the code i included with this thread abovewith the rows and columns working in conjunction with the rest of the site. I personally have tried everything i could think of. If you can do it visit the conest forum on this site and feel free to win the $100 bucks. Alittle extra cash for ya if you can do it. Thank you I do appreciate the help.


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
  •