SitePoint Sponsor

User Tag List

Page 19 of 31 FirstFirst ... 915161718192021222329 ... LastLast
Results 451 to 475 of 767
  1. #451
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    guests can post on certain threads designate by them upstairs.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  2. #452
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    don't forget php.net and mysql.com

  3. #453
    john
    SitePoint Community Guest
    I know this is probably old, but how would I go about paginating the results? I know this is pretty nice, and functions well... but say I wanted to limit each page of thumbnails to 20, and then create a second page for the next 20, and so forth. I can't find a logical way of doing it with this code. Any ideas?

  4. #454
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I also have to add something to this already very old thread, but I was trying to play around with the modified version of DrewF's code, posted here:

    http://www.sitepoint.com/forums/atta...chmentid=16100

    And I ran into a problem trying to implement a sorted output of the the thumbnails. Is there any way to allow sorting to show the newest posted thumbnails first? What I mean is, ORDER BY photo_id DESC, and have it added on to the original query, which looks like this (to fetch the thumbnails correctly)...

    UPDATE

    Edit: After trying again for the what seems like 20th time, with the same query, I managed to fix it. So, for any of you looking for the same thing, I used this line:

    PHP Code:
    $result = @mysql_query"SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."'  ORDER BY photo_id DESC LIMIT $from$max_results"); 
    This goes right after these lines:

    Code:
                    // Figure out the limit for the query based
                    // on the current page number.
                    $from = (($page * $max_results) - $max_results);
    This will sort the thumbnail view pages by the highest id first, meaning, the newest uploaded image will be the first, going to the oldest image.


    Edit 2:

    Also, I have a second problem that I forgot to mention.

    I know there was some talk of a better resize solution for creating the thumbnails. I tried all of them, but had no luck.

    What I was trying for, was, the images were to be created (if larger) with the maximum allowed width, and have a proportionately scaled down height to match that maximum width. So it would have the correct ratio.

    If too small, allow the size to remain the same.

    However, I cannot for the love of god, find anything that works the right way, there is always some logical flaw in the code I find or try to create.

  5. #455
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by NTGre
    I m trying to make a search .php so users can search my database and view the results the same way we use in index.php.........
    but the results are poor :'(

    Can any1 Help me????
    I've used this code. you can use boolean mode but thats for databases that have more than 50+ records within it.

    PHP Code:
    <?php
            
    include "config.inc.php";
            
            
    $query_array = array();
            
    $counter 0;
            
            
    // recieve the word to search for
            
    $word = ($_POST['word']);

                    
    $number_of_thumbs_in_row 1;

                    
    // query the database for this word
                    
    $query = @mysql_query"SELECT photo_id, photo_filename, photo_caption, etc.. FROM gallery_photos WHERE photo_caption LIKE '%".$word."%' OR photo_details LIKE '%".$word."%' OR photo_des LIKE '%".$word."%' ORDER BY photo_id DESC LIMIT 0, 5 ");

                    
    $nr = @mysql_num_rows$query );

                    if( empty( 
    $nr ) )
                    {
                            
    // if no reults display message below
                            
    $query_final "\t<tr><td><div align=\"center\"><strong><font face='Verdana, Arial, Helvetica, sans-serif' size='1'><span class='main_text'>No adverts found! Please try another word or phrase</span></font></strong></div></td></tr>\n";
                    }
                    else
                    {
                            while( 
    $row mysql_fetch_array$query ) )
                            {                                
                                
    // if word found get each photo and add padding on the left and right
                                
    $image_size getimagesize$images_dir.'/tb_'.$row[1] );
                                
                                if(
    $image_size[0] < 100)
                                {
                                     
    $width_size = (int)(120 $image_size[0]);
                                     
    $pad_r = (int)($width_size 2);
                                     
    $pad_l $pad_r;
                                }
                                else
                                {
                                     
    $pad_r 20;
                                     
    $pad_l 20;
                                }
                                
                                
    // list thumbnail(s) with details, etc..
                                
    $catquery = @mysql_query"SELECT category_name, category_id FROM gallery_category WHERE category_id='".addslashes($row[9])."'" );
                                    list(
    $category_name$category_id) = mysql_fetch_array$catquery );
                                    
    mysql_free_result$catquery );
                            
                                    
    $query_array[] = "<table width='400' border='0' cellspacing='0' cellpadding='0'>
          <tr> 
            <td width='120' valign='middle' rowspan='8'>
              <a href='"
    .$home_dir."/cat_user.php?cid=$category_id&pid=".$row[0]."'><img src='".$home_dir."/".$images_dir."/tb_".$row[1]."' border='0' alt='".$row[1]."' style='padding-top: 0px; padding-right: ".$pad_r."px; padding-left: ".$pad_l."px; padding-bottom: 0px;' /></a>
            </td>
            <td width='280' valign='top' bgcolor='#BDC8A4'><span class='view_gallery'>Title 
              :</span> 
    $row[2] </td>
          </tr>
            <td valign='top'><span class='view_gallery'>Category 
              :</span> <a href='"
    .$home_dir."/cat_user.php?cid=$category_id'>$category_name </a></td>
          </tr>
          <tr> 
            <td valign='top' bgcolor='#BDC8A4'><span class='view_gallery'>Age of equipment :</span> 
              
    $row[4]<span class='view_gallery'> Years and</span> $row[5]<span class='view_gallery'> months.</span></td>
          </tr>
          <tr> 
            <td valign='top'><span class='view_gallery'>Equipment location </span>: 
              
    $row[7] </td>
          </tr>
          <tr> 
            <td valign='top' bgcolor='#BDC8A4'><span class='view_gallery'>Details 
              :</span> 
    $row[8] </td>
          </tr>
        </table>
        <hr noshade align='center' size='1' width='400'>
        </td></tr>"
    ;
                            }
                            
    mysql_free_result$query );
                            
                            
    // display word used
                            
    $query_final "<tr><span class='main_text'>Adverts found with the word(s): ".$word."</span><br><br>";
     
                            
    // loop through until no more adverts can be found with that word
                            
    foreach($query_array as $thumbnail_link)
                            {
                                    if(
    $counter == $number_of_thumbs_in_row)
                                    {        
                                            
    $counter 1;
                                    }
                                    else
                                    
    $counter++;
                                    
                                    
    $query_final .= "\t<td><div align=\"center\">".$thumbnail_link."</div></td>\n";
                            }
                    }
    echo 
    "$query_final";
    ?>
    heres the search method i use, this goes into one page like search.php. you can search within any field you like, e.g. photo_caption. then add the search term "LIKE" with the word after it.

    with the use of "OR" you can add more feilds to search by using the same word.

    I've made an advanced search page which I'll post if you need to see it.

    I hope this will help, you will have to modify it to suit your needs and website.

    spence

  6. #456
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    spence, I tried your code, and it worked well (After being modified obviously).

    Do you see any way of adding pagination to the results if they go beyond the 6, or 5 you had it on?
    Last edited by ianfilms; Apr 13, 2006 at 07:46.

  7. #457
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    thats a good point, the code is in this thread earlier on. i'm in the process of doing another website using the same code. when i get to do this search section i'll have a look into pagination and post the results here.

  8. #458
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent, sounds good to me.

    I have another question for whomever has used this, and added to it.

    Has anyone built an image approval system for it? I really want to add image approval, so that I have to verify each image before it gets moved to the public database.

    I can't think of any way to do this, due to my lack of knowledge. Any suggestions?

    Edit: I've been trying to get something to work for a little while now, and I've had no luck. Dealing with checkboxes in a form should be straightforward if they are placed into an array, and then a foreach for a query based on each row within the array, should work... but it doesn't.
    Last edited by ianfilms; Apr 14, 2006 at 21:04.

  9. #459
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Earth
    Posts
    739
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I would say add another column to the gallery_photos table called approval and set the default to 0, once the image has been screened mark it as 1, then with in your queries add to them WHERE approval = 1

    Therefore only the images where approval matching 1 will display in the gallery.

    Create an admin page that has a query asking to show images WHERE approval = 0, and a drop down menu or textfield where u will echo its current status 0 and allow you to alter it to a 1 using the UPDATE function if its approved and a delete option to remove if it fails the screening process.

    hth

  10. #460
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, that's what I ended up doing, but it's messy as can be.

    I ended up having it display the thumbnail, and two buttons next to it. (Approve/Deny)

    If it get's denied, the "public" as I called it, gets set to 2, and is hidden from all queries. I don't want to add the deletion in yet, even though it's one simple line. (unlink)

    PHP Code:

    include "config.inc.php";

    function 
    showtable() {

    $result mysql_query"SELECT * FROM gallery_photos WHERE public='0'");
    $approve $_POST['approve'];
    $remove $_POST['remove'];
    $id $_POST['id'];
    $listapproval = array();

    echo 
    "<center><table>";

        while( 
    $listapproval mysql_fetch_array$result ) )
        {
            
    $addto[] = "<tr><form name=\"\" action=\"index.php\" method=\"POST\"><td><img src=\"imagedir/thumbs/tb/tb_$listapproval[1]\"></td>
            <td><input type=\"hidden\" value=\"
    $listapproval[0]\" name=\"id\"><input type=\"submit\" value=\"Approve Image\" name=\"approve\"><input type=\"submit\" value=\"Deny Image\" name=\"remove\"></td></form></tr>";
        }
        
        if(!empty(
    $addto)){
            foreach(
    $addto as $output)
            {
                echo 
    $output;
            }
        }
    mysql_free_result($result);

    }


    $approve $_POST['approve'];
    $remove $_POST['remove'];
    $id $_POST['id'];

        if(isset(
    $approve) && isset($id))
        {
            
    mysql_query("UPDATE gallery_photos SET public='1' WHERE photo_id='$id'");
            
    showtable();

        }
        else if(isset(
    $remove) && isset($id))
        {
            
    mysql_query("UPDATE gallery_photos SET public='2' WHERE photo_id='$id'");
            
    showtable(); 

        }
        else {
            
    showtable(); 

        } 
    Last edited by ianfilms; Apr 15, 2006 at 08:13.

  11. #461
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    ok all,

    here's the search page with page numbers (if over 8), next and prev.

    you will have to change the database settings and the thumbnail table, but thats it mostly.

    ok, copy all the script to 'search.php'. in your form you just need to set the text box name to 'word'. thats it.

    here's the code:
    PHP Code:
      <?php
              
    include "config.inc.php";
              
              
    $query_array = array();
              
    $counter 0;
              
              
    // recieve the word to search for
              
    $word = ($_POST['word']);
      
              
    $number_of_thumbs_in_row 4;
      
              
    // If current page number, use it
              // if not, set one!
      
              
    if(!isset($_GET['page'])){
                  
    $page 1;
              } else {
                  
    $page $_GET['page'];
              }
      
              
    // Define the number of results per page
              
    $max_results 8;
      
              
    // Figure out the limit for the query based
              // on the current page number.
              
    $from = (($page $max_results) - $max_results);
      
                     
    // query the database for this word in boolean mode
                  
    $query = @mysql_query"SELECT photo_id, photo_filename, photo_caption, etc... FROM gallery_photos WHERE photo_caption LIKE '%".$word."%' OR photo_details LIKE '%".$word."%' OR photo_des LIKE '%".$word."%' ORDER BY photo_date DESC LIMIT $from$max_results");
      
                     
    $nr = @mysql_num_rows$query );
      
                      if( empty( 
    $nr ) )
                      {
                          
    // if no reults display message below
                          
    $query_final "\t<tr><td><div align=\"center\"><strong><font face='Verdana, Arial, Helvetica, sans-serif' size='1'><span class='main_text'>No adverts found! Please try another word or phrase</span></font></strong></div></td></tr>\n";
                      }
                      else
                      {
                          while( 
    $row mysql_fetch_array$query ) )
                          {                          
                           
    // if word found get each photo and add padding on the left and right
                           
    $image_size getimagesize$images_dir.'/tb_'.$row[1] );
                           
                           if(
    $image_size[0] < 100)
                           {
                                
    $width_size = (int)(120 $image_size[0]);
                                
    $pad_r = (int)($width_size 2);
                                
    $pad_l $pad_r;
                           }
                           else
                           {
                                
    $pad_r 20;
                                
    $pad_l 20;
                           }
                           
                           
    // list thumbnail(s) with details, etc..
                           
    $catquery = @mysql_query"SELECT category_name, category_id FROM gallery_category WHERE category_id='".addslashes($row[9])."'" );
                               list(
    $category_name$category_id) = mysql_fetch_array$catquery );
                               
    mysql_free_result$catquery );
                             
                               
    $query_array[] = "<table align='left' width='405' border='0' cellspacing='1' cellpadding='1'>
            <tr> 
             <td width='120' rowspan='10' class='photo_boarder' bgcolor='#F9F9F9'><div align='center'><a href='"
    .$home_dir."index.php?cid=$category_id&pid=".$row[0]."'><img src='".$home_dir."/".$images_dir."/tb_".$row[1]."' border='0' alt='".$row[1]."' style='padding-top: 5px; padding-right: ".$pad_r."px; padding-left: ".$pad_l."px; padding-bottom: 5px;' /></a></div>
              </td>
          <td width='278' valign='top' bgcolor='#F9F9F9'><span class='style5'>Title :</span> 
    $row[2] </td>
            </tr>
            <tr>
             <td valign='top'><span class='style5'>Equipment location :</span> 
    $row[7] </td>
            </tr>
            <tr>
             <td valign='top' bgcolor='#F9F9F9'><span class='style5'>Buy Now Price :</span> 
    $row[13] </td>
            </tr>
            <tr>
             <td valign='top'><span class='style5'>Date Advert Added :</span> 
    $row[14] </td>
            </tr>
            <tr>
              <td>&nbsp;</td>
            </tr>
      </table><p>
      <table align='left' width='405' height='1' border='0' cellpadding='0' cellspacing='0'>
        <tr>
          <td><div align='left'>
            <hr size='1' noshade='noshade' color='#BFD475'/>
          </div></td>
        </tr>
      </table>
          </td>
              </tr>"
    ;
                              }
                          
    mysql_free_result$query );
                             
                          
    // display word used
                          
    $query_final "<tr><span class='main_text'>Adverts found with the word(s): ".$word."</span><br><br>";
       
                          
    // loop through until no more adverts can be found with that word
                       
    foreach($query_array as $thumbnail_link)
                              {
                                  if(
    $counter == $number_of_thumbs_in_row)
                                  {        
                                          
    $counter 1;
                                  }
                                  else
                                  
    $counter++;
                               
                               
    $query_final .= "\t<td><div align=\"center\">".$thumbnail_link."</div></td>\n";
                              }
                             
                          
    // Here check how many thumbs are displayed.
                          // If more than $max_results is set to build page number, prev, next links
                             
    if($counter)
                              {
                              if(
    $number_of_photos_in_row)
                                  
    $query_final .= "\t<td colspan='".($number_of_thumbs_in_row)."'></td>\n";
                                      
    $query_final .= "</tr>\n";
                          
    // Figure out the total number of results in DB:
                               
    $total_results mysql_result(mysql_query("SELECT COUNT(*) as Num FROM gallery_photos WHERE photo_category='".$category_id."' "),0);
      
                          
    // Figure out the total number of pages. Always round up using ceil()
                               
    $total_pages ceil($total_results $max_results);
      
                           if (
    $total_pages >1)
                           { 
    // build links if more than one page
      
                           // Build Page Number Hyperlinks
                               
    $query_final .= "<tr><td colspan='".$number_of_thumbs_in_row."'><span class='style5'>Showing Page: ".$page.' of '.$total_pages."</span><br>";
      
      
                           
    // Build Previous Link
                               
    if($page 1){
                                   
    $prev = ($page 1);
                                   
    $query_final .= "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$category_id&page=$prev\" title='Previous Page' class='style5'>&lt;&lt; Prev</a>";
                           }
      
                               for(
    $i 1$i <= $total_pages$i++){
                                   if((
    $page) == $i){
                                    
    $query_final .= "&nbsp;[$i]";
                               } else {
                                    
    $query_final .= "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$category_id&page=$i\" title='Page ".$i."' class='style5'>$i</a>";
                           }
                             }
      
                               
    // Build Next Link
                               
    if($page $total_pages){
                                   
    $next = ($page 1);
                                   
    $query_final .= "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$category_id&page=$next\" title='Next Page' class='style5'>Next &gt;&gt;</a>";
                               }
                          
    $query_final .= "\n</td></tr>";
                           }
                             else
                             {
              
    $query_final .=  "\n";
              }
          }
      }
      echo 
    "$query_final";
      
    ?>
    spence

  12. #462
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    blimey, i think we need 'Build An Automated PHP Gallery System In Minutes pt2'? lol

  13. #463
    Mads
    SitePoint Community Guest
    Hey , nice script. I was wondering if it would be easy to make a imageCopyResize with the big pict. I have been trying to do this for a longe time, but since I am pretty new to php, it gets pretty anoring when it don't work! ;)

    - Mads

  14. #464
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    doh!

    i've have noticed a small bug with in the search script when going back (prev). the script will pick up all data from the database which has the category id number.

    will work on this, when i get chance on thursday night.

    spence.

  15. #465
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)

    Talking

    hi all,

    i've sorted it out, finally

    the downside is a database is needed. it's only small.

    ok, i'll start off with the database creation first.

    you will need to create a new table in your database. name it 'gallery_search' or whatever want to. and add two fields, 1 = search_date & 2 = search_word.

    here's the mysql code to create the table with two fields:
    Code:
      CREATE TABLE `gallery_search` (
        `search_date` varchar(50) NOT NULL default '0',
        `search_word` varchar(250) NOT NULL default '',
        PRIMARY KEY  (`search_date`),
        KEY `search_id` (`search_word`)
      ) TYPE=MyISAM;
    the date will be needed for the results to be in order and later viewing.

    once the table has been added through phpMyAdmin (or whatever) make (or update your) search file with the following code:

    PHP Code:
      <?php
              
    include "config.inc.php";
              
              
    $query_array = array();
              
    $counter 0;
      
              
    // get the word from the html address
              
    if (!isset($_GET['searchword'])){
                  
    // recieve the word to search from search form
                  
    $word $_POST['word'];
                  
    $dbword $word;
                  
    // insert the word into the database
                 
    mysql_query"INSERT INTO gallery_search (search_date, search_word) VALUES(NOW(), '".$word."') ");
              } else {
                 
    // if no word from the form has been sent $_GET the word instead from the html address
                  
    $searchw $_GET['searchword'];
                  
    // select the word from the database
                 
    $search mysql_query"SELECT search_word FROM gallery_search WHERE search_word='".$searchw."' ");
                  
    $searchwr mysql_fetch_array$search );
                  
    $dbword $searchwr[0];
              }
              
              
    $number_of_thumbs_in_row 0;
      
              
    // if current page number, use it
              // if not, set one!
              
    if(!isset($_GET['page'])){
                  
    $page 1;
              } else {
                  
    $page $_GET['page'];
              }
      
              
    // define the number of results per page
              
    $max_results 8;
      
              
    // figure out the limit for the query based
              // on the current page number.
              
    $from = (($page $max_results) - $max_results);
      
                     
    // query the database for this word in boolean mode
                  
    $query = @mysql_query"SELECT photo_id, photo_filename, photo_caption, etc.. WHERE photo_caption LIKE '%".$dbword."%' OR photo_details LIKE '%".$dbword."%' OR photo_des LIKE '%".$dbword."%' ORDER BY photo_date DESC LIMIT $from$max_results");
      
                     
    $nr = @mysql_num_rows$query );
                      
                      
    // check $nr for results
                      
    if( empty( $nr ) )
                      {
                          
    // if no reults display message below
                          
    $query_final "<tr><td><div align=\"center\"><font face='Verdana, Arial, Helvetica, sans-serif' size='1'><span class='style5'>No adverts found! Please try another word or phrase</span></font></div></td></tr>";
                      }
                      else
                      {
                          while( 
    $row mysql_fetch_array$query ) )
                          {                          
                           
    // if word found get each photo and add padding on the left and right
                           
    $image_size getimagesize$images_dir.'/tb_'.$row[1] );
                           
                           if(
    $image_size[0] < 100)
                           {
                                
    $width_size = (int)(120 $image_size[0]);
                                
    $pad_r = (int)($width_size 2);
                                
    $pad_l $pad_r;
                           }
                           else
                           {
                                
    $pad_r 20;
                                
    $pad_l 20;
                           }
                           
                           
    // list thumbnail(s) with details, etc..
                           
    $catquery = @mysql_query"SELECT category_name, category_id FROM gallery_category WHERE category_id='".addslashes($row[9])."'" );
                               list(
    $category_name$category_id) = mysql_fetch_array$catquery );
                               
    mysql_free_result$catquery );
                             
                               
    $query_array[] = "<tr>
                                   <td>
                                    <table align='left' width='405' border='0' cellspacing='1' cellpadding='1'>
            <tr> 
             <td width='120' rowspan='10' class='photo_boarder' bgcolor='#F9F9F9'><div align='center'><a href='"
    .$home_dir."index.php?cid=$category_id&pid=".$row[0]."'><img src='".$home_dir."/".$images_dir."/tb_".$row[1]."' border='0' alt='".$row[1]."' style='padding-top: 5px; padding-right: ".$pad_r."px; padding-left: ".$pad_l."px; padding-bottom: 5px;' /></a></div>
              </td>
          <td width='278' valign='top' bgcolor='#F9F9F9'><span class='style5'>Title :</span> 
    $row[2] </td>
            </tr>
            <tr>
             <td valign='top'><span class='style5'>Equipment location :</span> 
    $row[7] </td>
            </tr>
            <tr>
             <td valign='top' bgcolor='#F9F9F9'><span class='style5'>Buy Now Price :</span> 
    $row[13] </td>
            </tr>
            <tr>
             <td valign='top'><span class='style5'>Date Advert Added :</span> 
    $row[14] </td>
            </tr>
            <tr>
              <td>&nbsp;</td>
            </tr>
      </table>
          </td>
              </tr>"
    ;
                              }
                          
    mysql_free_result$query );
                             
                          
    // reults - display message below
                          
    $query_final "<tr><td><div align='left'><font face='Verdana, Arial, Helvetica, sans-serif' size='1' class='style5'>Search results</font></div></td></tr>";
                             
                          
    // loop through until no more adverts can be found with that word
                       
    foreach($query_array as $thumbnail_link)
                              {
                                  if(
    $counter == $number_of_thumbs_in_row)
                                  {        
                                          
    $counter 1;
                                  }
                                  else
                                  
    $counter++;
                               
                               
    $query_final .= "<td><div align=\"center\">".$thumbnail_link."</div></td>";
                              }
                             
                          
    // figure out the total number of results in DB:
                               
    $total_results mysql_result(mysql_query("SELECT COUNT(*) as Num FROM gallery_photos WHERE photo_caption LIKE '%".$dbword."%' OR photo_details LIKE '%".$dbword."%' OR photo_des LIKE '%".$dbword."%' "),0);
                               
                          
    // here check how many thumbs are displayed.
                          // if more than $max_results is set to build page number, prev, next links
                          
    if ($total_results == 8)
                          { 
    // build links for one page only
      
                           // build Page Number Hyperlinks
                               
    $query_final .= "<tr><td colspan='".$number_of_thumbs_in_row."'><span class='style5'>Showing Page: 1 of 1</span><br>";
                             } else {
                           
    // build more than one page if counter is more than 8        
                           // figure out the total number of pages. Always round up using ceil()
                           
    $total_pages ceil($total_results $max_results);
                               
                           
    // build Page Number Hyperlinks
                               
    $query_final .= "<tr><td colspan='".$number_of_thumbs_in_row."'><span class='style5'>Showing Page: ".$page.' of '.$total_pages."</span><br>";
                           
                           
    // build Previous Link
                               
    if($page 1){
                                   
    $prev = ($page 1);
                                   
    $query_final .= " <a href=\"".$_SERVER['PHP_SELF']."?searchword=".$word.$searchwr[0]."&page=$prev\" title='Previous Page' class='style5'>&lt;&lt; Prev</a>";
                           }
      
                               
    // build the number of pages
                               
    for($i 1$i <= $total_pages$i++){
                                   if((
    $page) == $i){
                                    
    $query_final .= "&nbsp;[$i]";
                               } else {
                                    
    $query_final .= " <a href=\"".$_SERVER['PHP_SELF']."?searchword=".$word.$searchwr[0]."&page=$i\" title='Page ".$i."' class='style5'>$i</a>";
                               }
                           }
      
                               
    // build Next Link
                               
    if($page $total_pages){
                                   
    $next = ($page 1);
                               
    $query_final .= " <a href=\"".$_SERVER['PHP_SELF']."?searchword=".$word.$searchwr[0]."&page=$next\" title='Next Page' class='style5'>Next &gt;&gt;</a>";
                               
    $query_final .= "</td></tr>";
                           }
                           else
                           {
                               
    $query_final .= "<p>";
                           }
          }
      }
      echo 
    "$query_final";
      
    ?>
    some changes will be needed in the code to work with your database for your thumbnails, etc..

    the NOW() function is the DATE and TIME which will be placed into the field 'search_date' in the following format: yyyy-mm-dd hh:mm:ss (2006-05-02 11:17:18).

    'search_word' is for the word used to search. this will be useful for looking at what search words are being used for your pleasure.

    i'll make a page to view and delete them very soon.

    i think i've covered everthing, some more info in the post above, if you have any questions please post or pm.

    ta!

    spence

  16. #466
    SitePoint Member
    Join Date
    Jan 2004
    Location
    Edinburgh
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am having the same problems as this chap here. Can't think of anything else to change but 6 is my max number of files that upload fine. Anyone help with this as it's rather urgent I get this working Consider this a cry for help!

    Great script btw, works like a dream, apart form the 6 images issue



    Quote Originally Posted by gavacho
    I am using the code that was provided by Drew F as a zip package on this forum some time ago. It works fine except for one problem: It will only upload 6 images at a time. It will generate as many upload fields as I specify, but if for example I use 10 upload fields, it still will upload only 6 of the images. This problem was reported in three previous posts but the only solution offered was to check the php.ini settings.

    That is not the problem. I have post_max_filesize set to 50M and upload_max_filesize set to 50M, and the Apache directive limiting filesize disabled. All to no avail.

    It does not depend on filesize. Whether I try uploading 10M files, or 10Kb files, the result is the same: It will upload exactly six files. I have tried it on three different servers with the same result.
    Can anyone shed any light on this?

    P.S. I have created a version that uses ImageMagick, and a version that watermarks the images, and a version that allows video upload and display (all with the above mentioned problem). I am happy to share my experience with anyone interested in one of those features.

  17. #467
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    ^ need some code to look at.

    the form and the upload.php

    spence

  18. #468
    SitePoint Member
    Join Date
    Jan 2004
    Location
    Edinburgh
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spence_noodle
    ^ need some code to look at.

    the form and the upload.php

    spence
    I checked the form and upload code and can;t see anything wrong with it All thre max sizes are more than enough.

  19. #469
    SitePoint Addict
    Join Date
    Jan 2006
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This thread has helped me to devolop a image gallery which I have been looking to devolop and implement into a current site. Thank all it is an awesome topic, though somewhat confusing to me but a great way to learn being I am still a newbie. I have a question though. I have my site designed with 30 different categories, when you click the category there are different members belonging to each of the 30 categories. How can I make a page for each category then when you click the category> new page in same window opens with the first image of each member to that category. I am trying to build a dating site for where I live for locals. I have created 30 categories for each of the 30 cities in the surrounding area. Each of the category cities will have rouchly between 35-60 members with pics. How can I implement something like this with this script? Is it even possible???

  20. #470
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    yes it is. it will be a mysql command through your php script.

    if you look at my search script above you will see the database command starting with SELECT.

    the line you need to look at is this:
    PHP Code:
     mysql_query"SELECT photo_id, photo_filename, photo_caption, etc.. FROM gallery_photos WHERE photo_caption LIKE '%".$dbword."%' OR photo_details LIKE '%".$dbword."%' OR photo_des LIKE '%".$dbword."%' ORDER BY photo_date DESC LIMIT $from$max_results"); 
    so change it to select what data you require (e.g. = photo_id, photo_name, etc...) then point the command to which database to lookin (e.g. = gallery_photos). now ask the command to select the required data if a certain word/name matchies the one in that field (e.g. photo_caption = 'Mr Nice Guy'). you can limit the results to and have the results in descsending or ascsending order. the limit can be from 0 to 10, then from 11 to 20, etc...

    please see my search code above and past posts too.

    oh, forgot to mention, that you can have the results in ORDER BY date or time. this will require an extra field in your database with the date and time posted within it.

    this can be done when the new user registers for the first time by INSERTing the information into the datebase a bit like this:

    PHP Code:
      mysql_query"INSERT INTO gallery_datetime (search_date) VALUES(NOW()) "); 
    the NOW command will insert the date and time as the following format (you can change this to suit your needs) yyyy-dd-mm hh:mm:ss.

    i hope this helps, most can be found through past posts or from php.net and mysql.com

    also here at sitepoint

    regards

    spence

  21. #471
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey spence, I just got the message about your addition to the search with pagination. I tried your modified example, after you found the bugs, and had no luck. I'm going to spend free time once I graduate to go through it and make sure all the variables I'm using match up.

    I'll post any changes I make here.

    Thank you, again.

  22. #472
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    someone once posted a great contribution that allowed users to scan through previous and next photos while on the enlarged photo page.

    Does anyone remember where they saw this, I've lost it somewhere in the massive thread.

    Cheers,
    vibeX

  23. #473
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    you can do a search in this thread only.

    to do this go to the top of this page. then, where it says the page numbers, below you will see "Search This Thread".

    the rest is history

  24. #474
    SitePoint Member
    Join Date
    May 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Manyak, I have to say that this was an amazing feat for you to perform. Of all the CMS programs that I have toyed with and all of my personal failed attempts at generating a gallery code, I have to say that yours is top notch. Though when I tried to customize it to my own liking I failed miserably. I have never coded anything other than HTML. Thank you for starting something so great.

    Drewf, thank you. Your final release of this code has helped me to acheive exactly what I wanted.

    I cannot express enough gratitude to all who contributed to this code.

    I just have two questions/comments. Is it possible on the initial categories listing to post a random image from the specific category that is being listed or am I stuck with links on a page?

    Now I will probably show my newbie ranking and ask, is it possible to add next/previous links to the bottom of the page simply by doing some kind of pid=++ or pid=-- function. Forgive me for sounding a little lame, but somehow it makes sense in my head. This of course would only work if you uploaded your photos in the sequence that you would want them listed right?

  25. #475
    SitePoint Guru hisham777's Avatar
    Join Date
    Dec 2005
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi
    let me start by saying greate tutorial,

    ok here is the thing i followed the tutorial the Script is Wow.

    however am facing some difficulities with the script,

    when i load the preload.php i get this

    Notice: Undefined index: number_of_fields in E:\mysite\script\photoalbum\test\preupload.php on line 14

    Notice: Undefined variable: photo_category_list in E:\mysite\script\photoalbum\test\preupload.php on line 25

    then all add photos when uploading i get this

    Notice: Undefined offset: 5 in E:\mysite\script\photoalbum\test\upload.php on line 34


    and i can see the thumbs of the photos..


    whats this notice ?

    i trayed to fix it on my own no lack
    Never be shy to ask silly Qs
    An answer is always better than none


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
  •