Jump to content

SharkBait

Members
  • Posts

    845
  • Joined

  • Last visited

    Never

Posts posted by SharkBait

  1. Can't seem to quite figure out what query I need to do what I want.

     

    SELECT IFNULL(id, 0) as id1 FROM photo WHERE id < 3 LIMIT 1
    UNION
    SELECT IFNULL(id, 0) as id2 FROM photo WHERE id > 3 LIMIT 1
    

     

    Essentially I want to return 2 columns, the first one being from the top query and the second one for hte bottom query. But then a union isn't what i want is it?

     

    Then i tried to do a join

    SELECT t1.id as id1, It2.id as id2
    FROM photo as t1
    JOIN photo as t2 
    WHERE t1.id > 2 AND t2.id < 2
    

     

    But that didn't work either..

    What is it I am looking for?

    Trying to return the the row before and after a particular entry with 1 query as opposed to 2.

  2. Well it seems if within the .ajax() if I set async: false that worked, but then I had a weird reloading issue but putting event.preventDefault(); before the $.ajax seemed to fix that issue.

     

    Is this just some weird behaviour I am seeing or typical operating procedure?

  3. Ok this is bugging me, I'm trying to do a simple ajax request via a click of a link and even though Success triggers, the response is empty.

     

    <?php
    $pid = '123456789';
    ?>
    <script>
    $(document).ready(function() {
    		$('#clickme').click(function() {
    			alert('You have clicked me');
    			$.ajax({
    				url: 'getphoto.php',
    				type: 'GET',
    				data: {pid: '<?php echo $pid;?>'},
    				dataType: 'html',
    				success: function(data) {
    					alert('Data Sent: '+ data);
    					}
    				});
    
    		});
    	});
    </script>
    

     

    Then the php file:

    <?php
    if(isset($_GET['pid])) {
      $pid = $_GET['pid'];
    }
    
    echo 'You wanted to show a PID of: '. $pid;
    ?>
    

     

    Why do I get does this successed, but not return anything for `data`

  4. When you don't do something for a long time.. it slips from you! Or at least it does for me.

     

    RewriteRule ^([A-za-z]+)$ index.php?dir=$1 [L]
    

     

    What I want to accomplish is:

     

    blah.com/pix/Tree

    or

    blah.com/pix/Tugboat

     

    the index.php file within /pix will use the Tugboat or Tree as variables (via GET). Though.. the tricky part is that Tree an Tugboat will actually be directories with photos in them.

     

    The idea was to have /pix handle URL requests to display the photos within the specified directories. I don't want people to access the directories.

     

    Can it be done? Can we trick Apache into thinking there are no directories, when there are?

     

    Just creating a really quick and easy photo thing for myself. All i have to do is drop the photos into a directory and then blah.com/pix/racecar will allow me to display the photos within that directory via the index.php file that will style the single page.

     

     

  5. For some reason I cannot think today.

     

    <?php
    
    class {
    
      function meh() {
    
         $blah = $this->profile();
         echo $blah->weirdname;
      }
    
      function profile() {
         // this is where I'm stuck..
         // how do I properly set weirdname?
      }
    
    }
    ?>
    

     

    It's been a while since I've played with classes (been doing other things) so how do I set up the function profile() to return a value for weirdname.

     

     

  6. Am I right to assume that when you use wildcards (%) in a SELECT WHERE clause, that it will only match based on order of given terms?

     

    IE:

     

    SELECT * FROM name LIKE ('%this%that%')

     

    Will only match: 'something like this is like that', or ' this thing is that thing' etc?

     

    Where as

    SELECT * FROM name LIKE ('%that%this%')

    will not match any of the above, since the order of terms are reversed?

     

    I would assume that FULLTEXT search would be the ideal thing to use, right? Since the terms being looked up can be in no particular order?

     

     

  7. Linking to tables within the same database usually is done with fields that are similar.

     

    Table1 has a field called id

    Table2 has a field called table1_id

     

    Then you would link id from the first table to the value of the table1_id field. Make sense? The two tables need a relationship to be able to relate them.

  8. <?php
    $file = 'somelocation/the/new/file/goes/to.jpg';
    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $file) {
       // file has been move successfully
       $size = getimagesize($file);   // Width is first, Height is second and third argument is HTML for both
       if($size[0] > '1024') {
           // resize the photo
       } else {
           // Photo doesn't need to be resized.. continue
       }
    }
    ?>
    

     

    Is the roughly the idea :)

  9. Do you want to resize the photo to a maximum width if it is beyond it?

     

    On the file upload you can do a getimagesize() of the temp file that is uploaded to see if it's width is greater than the maximum you want too..

  10. Alright I've been tinkering around with creating my own stock photography site (for my photos) and trying to figure out the best way to handle the photos themselves.

     

    Typically a original sized JPG (after RAW conversion) of my photos can be around the 10MB mark and what I thought about doing is upload the original res photo and then use PHP to resize the photo to various sizes based on customers needs/wants.

     

    Currently I upload the original size. Thumbnails (at 300px long edge) are shown in a grid based on category or search term. You can hover over the thumbnail which will product a slightly larger photo (again sized by PHP off the original on the fly).

     

    When you view the 'details' of a photo, a 600px long edge photo is displayed (again php on the fly resize). Which seems to work fine on a single photo basis. Though, when displaying 12 photos per page (or whatever number) in the grid view and have PHP resize each from their originals to the thumbnail doesn't seem to be the most efficient use of PHP. Though this also could be the development server I run which might be a bit dated.

     

    When I upload the original, should I have PHP create a resized thumbail? Or having it handle the original files and resize when requested an alright alternative?

     

    When someone purchases a photo, after a sucessful checkout/payment/transaction I link back to the original but resize based on their selection and allow for the download. Is this alright to do as well, or will the PHP GD library allow for too much image quality loss? 

     

    Any info/thoughts/advice greatly appreciated!

     

    Cheers

  11. Alright...

     

    I've been working on a new site that will remove an existing site. (vague right?)

     

    The existing site is blog/database driven and receives decent amount of traffic for various searches related to the topics the blog is about.

     

    I've decided to change the way the site works and remove the blog aspect of it (i havent updated it in a LONG time). I have a couple other blogs (that I keep updating) and I want this new site just to be related to photos.

     

    The photos are added periodically so content won't be as stale as a photography portfolio site can be, but it won't be as dynamic as a blog might be if you updated on a somewhat daily basis.

     

    Would you leave the blog in there (which won't be used) and add the new site over top, or does it matter?

     

    I'm thinking of just removing the entire content that is currently there, and then replacing it with this new site I've created.

     

    I understand SEO works better with text, but I have a personal blog and a couple of other blogs that will probably point back to this portfolio site of mine.

     

    Hopefully that explains it... makes sense right? ;)

  12. I was about 6 years old (1986) and learning BASIC on a Commodore 64.

     

    Since then I've been tinkering around with various languages: Pascal/Turbo Pascal, C, C++, C#, VB.net, PHP and others.

     

    I'm actually going to school in the Fall to obtain the paper I need to prove to business I know what I am doing, since they require the piece of paper and not just look at the work I have done. People (in the business world) seem to fear Self-Taught people.

     

    :)

     

     

  13. Hello!

     

    I'm looking for small jobs that require the use of PHP/MySQL such as script fixing and script creating, adding additional functionality to existing sites, or whatever might be needed.

     

    I also LOVE WordPress. I live it, breath it and work with it everyday. I'm fairly intimate with the WordPress Codex and can help create themes (which can involve going from a PSD or AI file to a CSS/HTML Standards Compliant result), modify existing WordPress behavior and more. I also can take you from other blogging platforms such as Blogger/Blogspot, TypePad and other into the world of WordPress.

     

    If you have a job that you need to have done, or have some ideas for a job you would like to see completed, please send it my way via the message system here at phpFreaks.com or head over fill out a quick and easy form: DynamicShark

     

    Typically work is paid for via: Paypal

     

  14. I have over 4 years of PHP experience and looking to earn some extra cash by doing small jobs.

     

    By small jobs I mean, help with fixing website issues, adding features to websites that might utilize PHP and MySQL. Things that don't take multiple days to complete, unless you want me to charge you my typical hourly rate.

     

    I also design, develop and troubleshoot WordPress Themes and Plugins.

     

    Need to update your website to look a bit more modern? I can do that as well.

     

    Please send me a direct message through PHPFreaks with details about work you might want me to take a look at.

     

    Cheers!

  15. Okay, I'm trying to figure out what I am doing wrong here.

     

    I want to change the colour of a table's header (<th></th>) using CSS. This is what I have, but Firebug is showing its invalid or its ignoring it. Firefox is using the default a:link properties instead.

     

    <style>
    .files { background-color: #36c; }
    .files th a:link, .files th a:visited, .files th a:active { color:#fff; }
    </style>
    
    <table class="files">
    <tr>
      <th><a href="#">Link 1</a></th>
      <th><a href="#">Link 2</a></th>
    </tr>
    <tr>
      <td>Stuff here</td>
      <td>Stuff here too</th>
    </tr>
    </table>
    

     

    Does that not look right? Using Firefox with Firebug, it shows that its ignoring the .files portion of the style and using whatever the set a:link, a:visited, a:hover, a:active properties which makes the Link text the same colour as the background.

  16. Technically if they submit a form $_POST will always have at least the submit value set.

     

    Because it is set like an array you could try something like:

     

    <?php
    if(isset($_POST) && count($_POST) > 1) {
      //do stuff
      // form was submitted
    } else {
    //do something else
    // form submitted but no values were set
    }
    ?>
    

     

    So the $_POST variable has to have at least 2 or more values.

×
×
  • 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.