Jump to content

maxxd

Gurus
  • Posts

    1,698
  • Joined

  • Last visited

  • Days Won

    53

Everything posted by maxxd

  1. Sorry - it's early and all, but I'm not following that last comment (other than the typo bit). Post some code and more detail on the expected and actual results and we can get you moving in the right direction.
  2. Barand, Psycho - thanks so much! Looking at both suggestions together got me to where I needed to be. I ended up with this: SELECT * FROM tbl_feature_images WHERE (pg_id = :page) UNION SELECT * FROM tbl_feature_images WHERE NOT EXISTS (SELECT * FROM tbl_feature_images WHERE pg_id = :page) AND pg_id IS NULL UNION SELECT * FROM tbl_feature_images WHERE pg_id IS NULL AND display_order NOT IN (SELECT display_order FROM tbl_feature_images WHERE pg_id = :page) ORDER BY zone, display_order; which lets my user replace specific images in the rotation on a per-page basis. Y'all rock the hizzy - I would say 'I knew it was something easy', but it wasn't. Thank you much!
  3. Hey y'all. I'm having a bit of brain trouble here in that this seems like it should be really simple, but I'm just ... not coming up with the right query. Any help would be greatly appreciated. Basically, I've got three featured image 'zones' on each of the pages in my site. Each of the zones has a variable number of absolutely-placed images, stacked one on top of the other. Once the images are in place, my JavaScript takes over and cycles the opacity of each of the images in each of the zones in order from top to bottom, in effect rotating the images. That part I have working nicely, all the way around. However - and here's where my brain starts to stick - I want the site admin to be able to set site-wide default images for each zone, as well as page-specific images for each zone. So basically, if the page ID is in the featured images table, I want to select those images associated with that page ID. Otherwise, I want to select the images where page ID is null. I'm embarrassed to say that this is as far as I can get right now on it: SELECT fi.loc ,fi.title ,fi.alt ,fi.zone FROM tbl_featured_images fi WHERE fi.pageID = :page OR fi.pageID IS NULL ORDER BY fi.zone This isn't giving me the results I want (for obvious reasons). I feel like the answer's on the tip of my brain, I just can't quite seem to grasp it. Any suggestions? Many thanks in advance!
  4. You've still got to pass the variable to the function. $data = 'My data'; function test($data) { echo $data; } test($data);
  5. I agree with sKunKbad - stay away from global variables. If you're extending classes, make the parent class property protected and call it from the child class or inject the property through the constructor of the secondary class.
  6. You need JavaScript to do this. The extra files you allude to are probably LightBox, FancyBox, or Pretty Picture plugins. You'll need to download the files, upload them to your server, include them in your HTML, and then tag the images according to the docs for plugin you choose.
  7. Where are you setting $customernumber? Make sure you have error display turned on and see if the code is throwing any errors. You may also want to simply echo out $path and make sure you're looking where you think you're looking. Other thing, please be sure to use the code button [ <> ] in the text editor when posting code. It makes things easier to read.
  8. The username variable is not being passed by the sending page. Basically, however you get to this script is the issue. If the link on the sending page is "http://mysite.com/mypage.php", then it needs to be "http://mysite.com/mypage.php?username=myusername". If you're sending from a form, you'll need to make sure the form method is 'get' and there's a field in the form named 'username'.
  9. IMO, skip MysqlI and look into PDO - it's easier to use with prepared statements and parameter binding. The queries you've written are wide open to SQL injection. Using prepared statements will mitigate that risk.
  10. @requinix - good points all, and thank you for the in-depth explanation!
  11. I'll have to do some digging into regex - as I should have said, I'm terrible at them. I can't even read your string . Good point about double spaces, but wouldn't using array_filter() remove any empty elements? And exploding on a space would keep the periods at the end of words because it's before the space (or double space). Also, what non-word characters would have to be exploded upon? Interesting discussion about a topic I know woefully little about (let me know if this is now veering way off topic and I should open this in the miscellaneous section), so thanks much for expounding and explaining!
  12. I'm certainly not the best at regular expressions, but wouldn't it be easier to explode the sentence on ' ' and loop through the resulting array? $words = explode(' ', $sentence); for($i=0; $i<count($words); $i++){ if($i%2 == 0){ $words[$i] = 'MOD'; } } $sentence = implode(' ', $words); print("<p>{$sentence}</p>"); Or am I overlooking something obvious?
  13. Your links are incorrect to the actual javascript files - wowslider.js is not found on your server. Make sure you uploaded the files into the correct directory - www_root/old/steamsource/engine1/wowslider.js is where the page is looking for the script right now.
  14. Just to throw in here, I agree that starting with a procedural style does lessen the learning curve for the language as a whole. Once you're truly and thoroughly comfortable with php's functions, stylistic conventions, and quirks, you can set your eyes on OOP. The nice thing, as I'm sure you've already seen, is that php itself is becoming more and more object-oriented at the source, so you'll come across some to quite a bit of it even as you're learning procedural php and that should make the transition a little easier once you get to that point. As for OOP being overkill, I think it can be on occasion. That being said, I do find it easier (now, anyway) to code with objects in all of my projects. I work with WordPress every day and all of my custom code involves objects and classes; sure, the patterns may not be as robust as they would were I maintaining or creating a full-fledged framework or larger integrated system, but I do find it easier to think in terms of objects and classes. So now, any project I start from scratch is written OOP-style from the outset, then refactored as I go on for pattern adherence and ease of use and maintenance. Again, this is now - it took a lot of time for that shift in thinking to happen, and it was gradual and is still ongoing. That's really the biggest thing. You'll never completely learn php (or anything, really), so to answer your question - yes, you should include OOP in your learning schedule. You just don't have to include it yet - there's plenty of time, and plenty to learn.
  15. Plenty of suggestions right here.
  16. For storing the completed task list, I'd create a secondary table (completedTasks, maybe) and store the user ID and task ID. Only store a record if the task is complete - that way a simple join in your query will let you know know what's been finished and what's not. If you want, you could include a status column so that you could later allow the user to track percentage done, etc. As for the rest of your question, let us see your code as it stands now. It's difficult to offer advice and help if we don't know the starting point.
  17. If you only want to display the first index in your array, you don't need a loop at all. just print $events[0]. I get the feeling there's more to the code that we're not seeing, so it does make it a bit difficult to do anything other than throw something at the wall to see if it sticks...
  18. Turns out the #secondary aside was behind another div, which was blocking the mouse event. Yup, tired....
  19. Hey y'all. I'm either having a major brain fart or my eyes are entirely too tired today. I've got the following (this is obviously excerpted), and the :hover event on the #secondary aside is not firing in the HTML itself. In Firebug, selecting the :hover state for the #secondary aside behaves as expected. It just doesn't if I actually hover the mouse over the aside. Can anybody see what it is that I'm missing here? <style> #secondary:hover img, .entry-content .featured_image:hover img { opacity: .3; } #secondary:hover .testimonial, .entry-content .featured_image:hover .testimonial { opacity: 1; } .testimonial { position: absolute; top: 50%; left: 50%; -ms-transform: translateY(-50%) translateX(-50%); -webkit-transform: translateY(-50%) translateX(-50%); transform: translateY(-50%) translateX(-50%); width: 90%; font-weight: 700; font-family: 'Source Serif Pro', 'Georgia', 'Times New Roman', serif; color: #ffffff; opacity: 0; -webkit-transition: all 500ms ease-in-out; -moz-transition: all 500ms ease-in-out; -o-transition: all 500ms ease-in-out; transition: all 500ms ease-in-out; } </style> ... <aside id="secondary" class="right" role="complementary"> <div class="bg"><img src="http://mysite.com/path/to/existing/picture.jpg"></div> <div class="testimonial">"This is a testimonial" - a person</div> </aside>
  20. Try changing divobj.innerHTML = PremAmount.toFixed(2); to divobj.value = PremAmount.toFixed(2);
  21. In JavaScript, '+' is the concatenation operator. So, if your number is internally a string, ' + 1' will append the string '1' to the current value, thus turning '1' into '11'. As Muddy_Funster suggests, using parseInt() on the current value will make sure that JS sees the value as an integer and adding 1 will actually add 1 to the total.
  22. You've also got some problems beyond the sessions stuff as well. First off, the mysql_* functions are deprecated and scheduled for removal in the very near future. Check out PDO or mysqli classes. Secondly, you've got some issues here: $query = mysql_query("select * from members where password='$password' AND username='$username'", $connection); $result=mysql_query($sql); You're querying the database twice, and the variable $sql is undefined. You should be getting errors - do you have error reporting and display turned on? In addition to that, selecting all records, then running mysql_num_rows() on the result is inefficient - try this instead: SELECT COUNT(*) AS num_rows FROM members WHERE password = '{$password}' AND username='{$username}'; You can then check $result['num_rows'] after you run the query. One last thing - I don't see where you're encrypting your passwords before storing them in the database. You're not just storing plaintext passwords, are you?
  23. It's not that the code looked clunky, by any means. It's the base logic behind the data flow that I'm questioning. By calling to the database to get NOW(), you've used network and system resources to get the date; this is something very easily obtainable either from php or within the query itself, both of which negate the need for the first query which cuts down on network and system resources. It's sort of akin to using a JOIN in sql as opposed to running a sub-query on every loop through the result set of a parent query. Or, better yet, you wouldn't run a query to get all the user ID's from a table, then run an individual query for each user ID to get the user's name, right? And don't forget - as Psycho said - the point of this board is for everyone to learn. If you have a question, ask away - you'll probably learn something from the answer, and there's a good chance the people giving the answer will learn something, either by answering the question or from another user's answer (QUARTER() function, I'm looking at you). It's a win-win situation!
  24. @Landslyde, I gotta admit I couldn't agree more with Pyscho on this one. The way you've got it set up now is wasteful, resource-wise, and unnecessarily complex. When I typed out my answer, I'd read your question incorrectly in that I thought you had set the $year variable earlier in php - I chalk that up to lack of sleep. Psycho's query with Barand's suggestion of using the QUARTER() function is going to offer you the most flexibility and least unnecessary maintenance. As well as offering the fastest return time; as I said in my response, using substr() isn't the best idea, especially if you're not pulling the date from user input to inject into the query later.
  25. At the top of your code, add the following: if(!empty($_POST)){ print("<pre>".print_r($_POST,true)."</pre>"); }else{ print("<p>\$_POST is empty</p>"); } Just to make sure your post variables are being set like you think they are. The code looks like it should work (of course, I could be overlooking something obvious - I have a new puppy and am a bit sleep deprived), so making sure everything in post is set and indexed as expected should help a bit.
×
×
  • 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.