Jump to content

SharkBait

Members
  • Posts

    845
  • Joined

  • Last visited

    Never

Everything posted by SharkBait

  1. Anytime something shows up with [http://afdasdfsaf] I guess anytime a URL shows up within square braces, i want to remove the square braces and the contents within them I just want the the [http://afdasdfsaf] removed. Sorta like BBCode, but it isnt
  2. So how do I go about using preg_replace() to remove a portion of a string and ignoring the rest of it? String: [http://this.is.my.site.com/stuff/funn] this is cool! so that it only returns this is cool! I can't seem to get the regex pattern right
  3. 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.
  4. The php portion.. doesn't do anything with $custid your first query just pulls ALL the data You need to iterate through the array that $row will be to get it to display anything.
  5. Oh yea.. <a id="clickme" href="#">Click Me</a> Sort of thing
  6. 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?
  7. 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`
  8. What I decided to do was rename the directories to have a character similar to them blahblah-p and then when someone goes to blah.com/pix/blahblah it will pull the files from blahblah-p directory if it exists. *shrug*
  9. 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.
  10. 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.
  11. 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?
  12. 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.
  13. Typically when dealing with checkboxes, if you want 1 checkbox to allow all checkboxes checked it would be done with javascript. If you want PHP to check off all checkboxes within a loop you would add checked="checked" to the html code of the checkbox themselves.
  14. <?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
  15. 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..
  16. 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
  17. 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?
  18. 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.
  19. 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.
  20. 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.
  21. if you want something to change during php portion after the form is submitted you would check to see if the value is set: <?php ... if(isset($_POST['mycheckbox'])) { //do stuff here } ?> .. .. <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <input type="checkbox" name-"mycheckbox" /> ... </form> that make sense?
  22. I thought extends worked on adding new functionality to existing classes? I'm looking to utilize 2 completely separate classes? Can I do something like this? <?php global $MySQL; $MySQL = new MySQL(); $MyLink = $MySQL->Connection('servers stuff here'); ... $CustomerInfo = new CustomerInfo('MyCompany', $MySQL, $MyLink); $CustomerInfo->fetchAddress(); // This uses $MySQL within the class to run queries echo $CustomerInfo->getAddress['city']; echo $CustomerInfo->getAddress['country']; ?> Would I "global $MySQL;" inside the CustomerInfo class too?
  23. Is it possible to have a class use another class? I have a MySQL class with some basic options: $MySQL->Connect() $MySQL->DoQuery() $MySQL->FetchArray() $MySQL->Disconnect() Now I am creating a new class to pull address information from a database. <?php class CompanyInfo { private $company; public $address; // array for like address, city, state, country etc. function __construct($company); $this->company = $company; } function fetchAddress() { // How do I use $MySQL->Connect(), $MySQL->DoQuery() etc here?? // Will store information from data in class to be used whenever } function getAddress() { // Pull address information on a needed basis } ?> Am I doing this right? Im getting tired of repeating a lot of my code
×
×
  • 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.