SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member cybermob's Avatar
    Join Date
    Jan 2004
    Location
    Baltimore
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question question about table columns after a search query

    just curious i am trying to make 2 columns with my search query results, have everything working great except this ....not sure how i would go about it ? here is my noobie code hehe

    PHP Code:
    <?php
    include("checkme.php");
    $mqsearch $_GET['mqsearch'];
    include(
    "util.php");

    if(!isset(
    $_GET['page'])){
        
    $page 1;
        } else {
        
    $page $_GET['page'];
        }
    $mqsearch $_GET['mqsearch'];
    $max_results 3;
    $q $mqsearch;
    $from = (($page $max_results) - $max_results);
    $sql mysql_query("SELECT * FROM macontact WHERE MATCH (firstname,lastname,customer,talent) AGAINST ('%$q*%' IN BOOLEAN MODE) LIMIT $from$max_results");
    while(
    $row mysql_fetch_array($sql)){

    echo (
    "<a href='mysite.php?info=$row[customer]'><table width='234' height='103' border='0' cellpadding='0' cellspacing='0'>");
    echo  
    "<tr>";
    echo  
    "<td colspan='2' rowspan='2'> <img src='images/BUSCARD_01.gif' width='13' height='14' alt=''></td>";
    echo   
    "<td colspan='4'> <img src='images/BUSCARD_02.gif' width='206' height='5' alt=''></td>";
    echo   
    "<td colspan='3' rowspan='2'> <img src='images/BUSCARD_03.gif' width='14' height='14' alt=''></td>";
    echo   
    "<td> <img src='images/spacer.gif' width='1' height='5' alt=''></td>";
    echo   
    "</tr>";
    echo   
    "<tr>" ;
    echo    
    "<td colspan='4'> <img src='images/BUSCARD_04.gif' width='206' height='9' alt=''></td>";
    echo    
    "<td> <img src='images/spacer.gif' width='1' height='9' alt=''></td>";
    echo   
    "</tr>";
    echo   
    "<tr>" ;
    echo    
    "<td rowspan='4'> <img src='images/BUSCARD_05.gif' width='5' height='72' alt=''></td>";
    echo    
    "<td rowspan='9'> <img src='images/BUSCARD_06.gif' width='8' height='88' alt=''></td>";
    echo     
    "<td rowspan='4'> <img src='";
    echo    
    $row['headshot'];
    echo    
    "' width='75' height='72' alt=''></td>";
    echo    
    "<td rowspan='6'> <img src='images/BUSCARD_08.gif' width='9' height='79' alt=''></td>";
    echo    
    "<td colspan='3'> <img src='images/spacer.gif' width='130' height='1' alt=''></td>";
    echo    
    "<td rowspan='5'> <img src='images/BUSCARD_10.gif' width='5' height='75' alt=''></td>";
    echo    
    "<td rowspan='9'> <img src='images/BUSCARD_11.gif' width='1' height='88' alt=''></td>";
    echo    
    "<td> <img src='images/spacer.gif' width='1' height='5' alt=''></td>";
    echo    
    "</tr>";
    echo    
    "<tr>";
    echo    
    "<td rowspan='6'> <img src='images/spacer1.gif' width='19' height='77' alt=''></td>";
    echo    
    "<td colspan='2' valign='top'><div align='left'><font face='Arial, Helvetica, sans-serif'>";
    echo     
    $row['firstname'].$row['lastname'];
    echo     
    "</font></div></td>";
    echo     
    "<td> <img src='images/spacer.gif' width='1' height='25' alt=''></td>";
    echo     
    "</tr>";
    echo     
    "<tr>" ;
    echo     
    "<td colspan='2' valign='top'> <div align='left'><font face='Arial, Helvetica, sans-serif'>";
    echo     
    $row['customer'];
    echo      
    "  </font></div></td>";
    echo      
    "<td> <img src='images/spacer.gif' width='1' height='27' alt=''></td>";
    echo     
    "</tr>";
    echo      
    "<tr>";
    echo     
    "<td colspan='2' rowspan='2' valign='top'><div align='left'><font face='Arial, Helvetica, sans-serif'>";
    echo     
    $row['talent'];
    echo      
    "</font></div></td>";
    echo      
    "<td> <img src='images/spacer.gif' width='1' height='15' alt=''></td>";
    echo      
    "</tr>";
    echo      
    "<tr>" ;
    echo      
    "<td rowspan='5'> <img src='images/BUSCARD_16.gif' width='5' height='16' alt=''></td>";
    echo      
    "<td rowspan='2'> <img src='images/BUSCARD_17.gif' width='75' height='7' alt=''></td>";
    echo      
    "<td> <img src='images/spacer.gif' width='1' height='3' alt=''></td>";
    echo      
    "</tr>";
    echo      
    "<tr>" ;
    echo      
    "<td colspan='3' rowspan='2'> <img src='images/BUSCARD_18.gif' width='116' height='7' alt=''></td>";
    echo       
    "<td> <img src='images/spacer.gif' width='1' height='4' alt=''></td>";
    echo       
    "</tr>";
    echo       
    "<tr>";
    echo       
    "<td colspan='2'> <img src='images/BUSCARD_19.gif' width='84' height='3' alt=''></td>";
    echo       
    "<td> <img src='images/spacer.gif' width='1' height='3' alt=''></td>";
    echo       
    "</tr>";
    echo        
    "<tr>";
    echo       
    "<td colspan='4'> <img src='images/BUSCARD_20.gif' width='206' height='5' alt=''></td>";
    echo       
    "<td colspan='2' rowspan='2'> <img src='images/BUSCARD_21.gif' width='13' height='6' alt=''></td>";
    echo        
    "<td> <img src='images/spacer.gif' width='1' height='5' alt=''></td>";
    echo        
    "</tr>";
    echo        
    "<tr>";
    echo         
    "<td colspan='4'> <img src='images/BUSCARD_22.gif' width='206' height='1' alt=''></td>";
    echo         
    "<td> <img src='images/spacer.gif' width='1' height='1' alt=''></td>";
    echo         
    "</tr>";
    echo         
    "<tr>" ;
    echo        
    "<td> <img src='images/spacer.gif' width='5' height='1' alt=''></td>";
    echo        
    "<td> <img src='images/spacer.gif' width='8' height='1' alt=''></td>";
    echo        
    "<td> <img src='images/spacer.gif' width='75' height='1' alt=''></td>";
    echo        
    "<td> <img src='images/spacer.gif' width='9' height='1' alt=''></td>";
    echo        
    "<td> <img src='images/spacer.gif' width='19' height='1' alt=''></td>";
    echo        
    "<td> <img src='images/spacer.gif' width='103' height='1' alt=''></td>";
    echo        
    "<td> <img src='images/spacer.gif' width='8' height='1' alt=''></td>";
    echo         
    "<td> <img src='images/spacer.gif' width='5' height='1' alt=''></td>";
    echo        
    "<td> <img src='images/spacer.gif' width='1' height='1' alt=''></td>";
    echo        
    "<td></td>";
    echo         
    "</tr>";
    echo        
    "</table></a>";
    }

    $total_results mysql_result(mysql_query("SELECT COUNT(*) FROM macontact WHERE MATCH (firstname,lastname,customer,talent) AGAINST ('%$q*%' IN BOOLEAN MODE)"),0);

    $total_pages ceil($total_results $max_results);
    $searchme $mqsearch;
    $mqsearch $_POST['mqsearch'];

    echo 
    "<center>Select a Page<br />";

    if(
    $page 1){
        
    $prev = ($page 1);
        echo 
    "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev&mqsearch=$q\"><< Previous</a>";
        
    }

    for(
    $i 1$i <= $total_pages$i++){
        if((
    $page) == $i){
        echo 
    "$i";
        } else {
        echo 
    "<a href=\"".$_SERVER['PHP_SELF']."?page=$i&mqsearch=$q\"> $i</a>";
        }
        }
        
    if(
    $page $total_pages){
    $next = ($page 1);
    echo 
    "<a href=\"".$_SERVER['PHP_SELF']."?page=$next&mqsearch=$q\"> Next >></a>";
    }
    echo 
    "</center>";

    include(
    'footer.php'); 

    ?>

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not entirely sure what your question/problem is but i wouldn't echo wacking great chunks of HTML like that
    Better to break in and out of PHP mode, e.g.
    <html>
    ...some more html here..
    <?php some php here ?>
    ...some more html here..
    <?php more php etc..etc.. ?>
    </html>

  3. #3
    SitePoint Member cybermob's Avatar
    Join Date
    Jan 2004
    Location
    Baltimore
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    i wasnt sure if that would work?

    wasnt sure if getting in and out of php would work with this so havent tried that yet hehe.

    My main prob is right now my search results will come back to be in a single column straight down the page depending on how many i set per page.

    i would really like it to go 2 across and 4 down from the query results, so if i get 8 results it would show all 8 on the page instead of 4 on first page and 4 on second.

    just not sure how to structure the loop to do that

  4. #4
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This link should help you out...

    http://codewalkers.com/tutorials/15/1.html
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine

  5. #5
    SitePoint Member cybermob's Avatar
    Join Date
    Jan 2004
    Location
    Baltimore
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    IT worked !!!

    Thank you Toly !!! i get the concept now of doing columns in the search result, makes total sense now !!

    and thank you Mark1999 i just put the html right in with nestled php for the variables and everything worked perfectly , much cleaner now !!!


    Thanks all !!!!

  6. #6
    <?php echo"GiroPets"; ?> giropets's Avatar
    Join Date
    Jul 2003
    Location
    United States
    Posts
    242
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This works also :

    PHP Code:
    <?php
    // Random Value //
    $this "that";

    // Number of columns that you want to show //
    $cols "2";

    // Percent in which you wish to have your columns //
    $width "50";

    // MySQL Queries //
    $query1 mysql_query("SELECT * FROM tblName WHERE something='$this'") or exit("Please Contact Admin :  " mysql_error());
    $query2 mysql_num_rows($query1);

    // No results, display an error //
    if($query2 == "0"){exit("No results to display.");}

    // Counting -- DO NOT CHANGE //
    $count "0";

    // Show the table and the first tr row //
    echo"<table border='1' width='100%'>
    <tr valign='top' align='center'>"
    ;

    // Looping the Queries //
    while($query3 mysql_fetch_array($query1)){

    // Updating the count //
    $count $count +1;

    // Showing info //
    echo"<td width='$width'>$query3[var1] - $query3[var2]</td>";

    // If the count is greater than or equal to the columns set in the settings, make a new row and set the counting to '0' //
    if($count >= "$cols"){echo"</tr><tr valign='top' align='center'>";$count "0";}

    // End your table //
    echo"</table>";

    }

    ?>
    Just to let you know.


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
  •