Jump to content

HCProfessionals

Members
  • Posts

    107
  • Joined

  • Last visited

Posts posted by HCProfessionals

  1. Everything works great, except the part where I am trying to get the mysql_num_rows for each category - $jobsc_row['job_category']
     

    <?php
    $jobsc_query = "SELECT j.id, j.jobc_name, c.job_category FROM site_jobscats AS j LEFT JOIN site_jobs AS c ON j.id=c.job_category WHERE jobc_active='1'";
    $jobsc_result = mysql_query($jobsc_query) or die("There was a problem with the SQL query: " . mysql_error());
    while ($jobsc_row = mysql_fetch_array($jobsc_result)) {
       $jobcatid = $jobsc_row['id'];
       $jobcatname = $jobsc_row['jobc_name'];
       $jobcatcount = mysql_num_rows($jobsc_row['job_category']);
       echo "<li><a href=\"jobs.php?cat=$jobcatid\">$jobcatname [$jobcatcount]</a></li>";
    }
    ?>
    
  2. <script type="text/javascript">
       $(document).ready(function() {
           $("#photo_id").fancybox().trigger('click');
       });
    </script>

     

    I'm triggering a specific photo in fancybox when the page loads. How can I put the following options inside of the function?

     

    
    boxOptions: { 
    beforeShow: function () {
                if (this.title) {
                    this.title += '<br /><br />';
    this.title += '<img src="../wallpapers/images/facebook.png" border="0" /> <a href="http://www.facebook.com/sharer.php?u=' + this.href + '" target="_blank">Share on Facebook</a>';
    this.title += ' | ';
    this.title += '<a href="http://pinterest.com/pin/create/button/?url=' + this.href + '" class="pin-it-button" count-layout="horizontal"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a>';
    this.title += ' | ';
    this.title += '<iframe src="//www.facebook.com/plugins/like.php?href=' + this.href + '&layout=button_count&show_faces=false&width=500&action=like&font&colorscheme=light&height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:23px;" allowTransparency="true"></iframe>';
                }
            },
            helpers : {
                title : {
                    type: 'inside'
                },
            }  
      }

  3. Currently I'm using the asort function to list by filename, but I'm trying to list by filetime to order from most newest file upload to oldest.

     

     function listQueue($queue, $path)
     {
      arsort($queue);
      foreach ($queue as $file)
      {
       listFile($file, $path);
      }
     }
    
    
     function listFile($file, $path)
     {
      list($width, $height, $type, $attr) = getimagesize($path.$file);
      $image_size = imageSize($path.$file);  
    
      echo "<a href=\"".$path.$file."\"><img src=\"getimage.php?img=".str_replace("./download/", "", $path.$file)."&w=140&h=79\" alt=\"".date("F d, Y", filemtime($path.$file))."\" title=\"Resolution: ".$width."x".$height.". Filesize: ".$image_size.". Date Uploaded: ".date("F d, Y", filemtime($path.$file)).".\" /></a>";
     }
    

  4. I am having a difficult time displaying arrays to an actual file list

     

    What I currently have for code:

    <?php
    $dir = 'download/';
    $results = array();
    if (is_dir($dir)) {
    $iterator = new RecursiveDirectoryIterator($dir);
    foreach ( new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file ) {
    if ($file->isFile()) {
    $thispath = str_replace('\\', '/', $file);
    $thisfile = utf8_encode($file->getFilename());
    $results = array_merge_recursive($results, pathToArray($thispath));
    }
    }
    }
    echo "<pre>";
    print_r($results);
    
    
    function pathToArray($path , $separator = '/') {
    if (($pos = strpos($path, $separator)) === false) {
    return array($path);
    }
    return array(substr($path, 0, $pos) => pathToArray(substr($path, $pos + 1)));
    }
    ?>
    

     

    Which Will Display:

    
    Array
    (
    [download] => Array
    (
    [folder1] => Array
    (
    [0] => image1.jpg
    [1] => image2.jpg
    [2] => image3.jpg
    [3] => image4.jpg
    [4] => image5.jpg
    )
    
    [folder2] => Array
    (
    [0] => image1.jpg
    [1] => image2.jpg
    [2] => image3.jpg
    [3] => image4.jpg
    [4] => image5.jpg
    )
    )
    )
    

     

    What I am looking for as a display:

     

    - Not to show the download folder, only subs

     

    <div class="images">
    <div title="folder1">
    <img src="download/folder1/image1.jpg" />
    <img src="download/folder1/image2.jpg" />
    <img src="download/folder1/image3.jpg" />
    <img src="download/folder1/image4.jpg" />
    <img src="download/folder1/image5.jpg" />
    </div>
    
    <div title="folder2">
    <img src="download/folder2/image1.jpg" />
    <img src="download/folder2/image2.jpg" />
    <img src="download/folder2/image3.jpg" />
    <img src="download/folder2/image4.jpg" />
    <img src="download/folder2/image5.jpg" />
    </div>
    </div>
    

  5. I figured it out after playing around.

     

    SELECT p.arc_pid, p.arc_pname, p.arc_pdescription, p.arc_pprice, p.arc_pbuylink, i.arc_ilink, c.arc_cid, c.arc_cname FROM arc_products AS p LEFT JOIN arc_images AS i ON p.arc_pid=i.arc_pid LEFT JOIN arc_categories AS c ON p.arc_pcategory=c.arc_cid WHERE arc_pactive='1' ORDER BY FIELD(arc_cid, '1') DESC, arc_pname ASC

  6. Ok, here's my current query:

     

    SELECT p.arc_pid, p.arc_pname, p.arc_pdescription, p.arc_pprice, p.arc_pbuylink, i.arc_ilink, c.arc_cid, c.arc_cname FROM arc_products AS p LEFT JOIN arc_images AS i ON p.arc_pid=i.arc_pid LEFT JOIN arc_categories AS c ON p.arc_pcategory=c.arc_cid WHERE arc_pactive='1' ORDER BY arc_cid ASC, arc_pname ASC

     

    What I want is to sort where arc_cid='1' then sort the rest by arc_pname ASC. I'm sure I'll have to use a case, but I'm just not sure.

  7. I'm pulling a date from an RSS Feed and need to convert it to something a little nicer. Possible?

     

     

    Current Date:

     

    Tue, 12 Jun 2012 07:49:25 PDT

     

    What I want:

     

    Tuesday, June 12, 2012

  8. I am building a program to allow users to include a bio for themselves. The problem is, if they enter a special character into the textarea, MySQL throws errors. How can I fix this?

  9. As was said before, you're not defining $option_name or $option_price. You're doing those statements backwards, you're saying that the first key in $option_part should be set to the value within $option_name. $option_name does not exist. Switch it around.

     

    Wow, totally missed that. Thank You!!!!

  10. I'm not really getting anywhere...

     

    					$option_results = mysql_query("SELECT product_options FROM products WHERE product_id='".$product."'");
    					while($option_row = mysql_fetch_array($option_results)){
    							$sep_option = explode("::", $option_row[0]);
    							foreach ($sep_option as $sep_result)
    							{
    								$option_part = explode(",", $sep_result);
    								$option_part[0] = $option_name;
    								$option_part[1] = $option_price;
    								echo "<li class=\"product\" id=\"option-".$option_name."\"><input class=\"purchase\" type=\"button\" value=\"Add to cart\"><span class=\"title\">".$option_name."</span>, Add $<span class=\"price\">".$option_price."</span></li>";
    							}
    
    					}

  11. I'm trying to add options to products.

     

    Currently, I have them in this format: Leather reinforced hilt,5.00::Stabbing tip,3.00::Logo,10.00

     

    $option_results = mysql_query("SELECT product_options FROM products WHERE product_id='".$product."'");
       while($option_row = mysql_fetch_array($option_results)){
             $option = explode("::", $option_row[0]);
             $option_part = explode(",", $option[0]);
             $option_part[0] = $option_name;
             $option_part[1] = $option_price;
             echo "<li><a href=\"#\">".$option_name.", Add $".$option_price."</a></li>";
        }
    

     

    I would like the output to be:

     

    <li><a href="#">Leather reinforced hilt, Add $5.00</a></li>

    <li><a href="#">Stabbing tip, Add $3.00</a></li>

    <li><a href="#">Logo, Add $10.00</a></li>

  12. I have this so far, but it isn'tworking...

     

    <script type="text/javascript" language="javascript">
        $(document).ready(function() {
    
          $("#product-image-buy-link").click(function(){
             $("#top-bar-content-items").effect( "highlight", 
              {color:"#FFF"}, 3000 );
          });
    
       });
       </script>
    
    
    <span id="top-bar-content-items">You have <span class="cart-quantity">0</span> products in your cart</span>
    
    <span id="product-image-buy-link" class="purchase">add to cart</span>
    

  13. products table

    product_id, cat_id, product_name, product_desc, product_price, product_featured, product_inv, product_date, product_active

     

    product_images table

    image_id, product_id, image_name, thumb, image_date

     

    Step 1:

    Featured Area: There are several images per item and the thumbnail is based on which image has thumb=1 to make it easy to change the thumbnail for each product. If I don't have the thumbnail indicated in the sql query, it will pull all the images and insert multiple rows from the same product when it is pulled from the database.

     

    Step 2:

    Random Products: At the bottom of the page is 10 random products with their thumbnail shown. If you click on the thumbnail it will open a slideshow (similar to lightbox) with more information for the product. I have never done anything quite this advanced and is really where I need help with how the SQL statements are made along with PHP.

     

    Thank you for the help as I know I am frustrating!

  14. I need to figure out how to make this work with the 2 queries. Everything but the $mfimages_results works.

    I really don't want to use Join, because with the rules I can only pull the thumbs and if I leave the thumbs rule out, it messes everything up.

     

                          <?php
    			//Featured Item Data
    			$mfeatured_results = mysql_query("SELECT * FROM products WHERE product_featured='1' AND product_active='1'");
    
    			//Featured Item Images
    			$mfimages_results = mysql_query("SELECT image_name FROM product_images WHERE product_id='".$mfeatured_row['product_id']."' AND thumb='1'");
    
    			$mf_i=0;
    			while($mfeatured_row = mysql_fetch_assoc($mfeatured_results))
    			{
    				$imgClass = ($mf_i==0) ? 'home-slider-photo preload' : 'home-slider-photo preload home-slider-photo-unsel';
    				$priceClass = ($mf_i==0) ? 'home-slider-photo-price' : 'home-slider-photo-price home-slider-photo-price-unsel';
    				$descClass = ($mf_i==0) ? 'home-slider-description' : 'home-slider-description home-slider-description-unsel';
    
    				$mf_thumbs .=  "<img id=\"home-slider-photo-".$mf_i."\" class=\"".$imgClass."\" src=\"/includes/getimage.php?img=".$mfimages_results[0]."&w=370&h=370\" alt=\"\" />\n";
    				$mf_prices .=  "<div id=\"home-slider-photo-price-".$mf_i."\" class=\"".$priceClass."\"><span>only</span>$".$mfeatured_row['product_price']."</div>\n";
    				$mf_vars .=  "app.slider.vars.productUrl[".$mf_i."] = '?".$mfeatured_row['product_id']."';\n";
    				$mf_description .=  "<div id=\"home-slider-description-".$mf_i."\" class=\"".$priceClass."\"><h2>".$mfeatured_row['product_name']."</h2><p>".$mfeatured_row['product_desc']."</p></div>\n";
    
    			$mf_i++;
    			}
    			?>

  15. Everything works except for the data needed for "$f_images", which what I am trying to get is the multiple images for each product.

     

                	<?php
    			$featured_results = mysql_query("SELECT * FROM products JOIN product_images ON products.product_id=product_images.product_id WHERE products.product_active='1' AND thumb='1' Limit 10");
    
    			while($featured_row = mysql_fetch_assoc($featured_results))
    			{
    				//Thumbnail Query
    				$fthumb_result = mysql_query("SELECT image_name FROM product_images WHERE product_id='".$mfeatured_row['product_id']."' AND thumb='1'");
    				$fthumb = mysql_fetch_row($fthumb_result);
    
    				$fimages_result = mysql_query("SELECT image_name FROM product_images WHERE product_id='".$featured_row['product_id']."'");
    				while($fimages_row = mysql_fetch_assoc($fimages_result))
    				{
    					$f_images .= "'/includes/getimage.php?img=".$fimages_row[0]."&w=224', ";
    				}
    
    				$f_vars .=  "\nproductId = ".$featured_row['product_id'].";\napp.isotope.vars.homeFeaturedImages[productId] = [".$f_images."];\napp.isotope.vars.homeFeaturedProducts[productId] = {\nname  : \"".$featured_row['product_name']."\",\nprice : \"".$featured_row['product_price']."\",\nurl   : '/'\n};";
    
    			}
    			?>

  16. :shrug:

     

    <?php
    $featured_results = mysql_query("SELECT * FROM products JOIN product_images ON products.product_id=product_images.product_id WHERE products.product_featured='1' AND products.product_active='1' AND thumb='1'");
    $i=0;
    while($row = mysql_fetch_assoc($featured_results))
    {	
    $fthumb_result = mysql_query("SELECT image_name FROM product_images WHERE product_id='".$row['product_id']."' AND thumb='1'");
    $fthumb = mysql_fetch_row($fthumb_result);
    
    if ($i==0) {
    	$first_html .=  "\n<img id=\"home-slider-photo-".$i."\" class=\"home-slider-photo preload\" src=\"/includes/getimage.php?img=".$fthumb[0]."&w=370&h=370\" alt=\"\" />";
    } else {
    	$first_html .=  "\n<img id=\"home-slider-photo-".$i."\" class=\"home-slider-photo preload home-slider-photo-unsel\" src=\"/includes/getimage.php?img=".$fthumb[0]."&w=370&h=370\" alt=\"\" />";
    };
    
        $i++;
    }
    echo "$first_html";
    ?>

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.