Jump to content

galvin

Members
  • Posts

    614
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

galvin's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. Thanks very much for your insight!
  2. I have been tasked with attempting to recreate a web app that allows a user to upload a photo and then cut out a specific part of an image that will be saved as a transparent PNG, with the main use being removing backgrounds from an image (i.e. cutting out a face to use as an avatar, etc) I found two online tools that already do this in different ways: 1. Smart Scissors: Quick video shows how you can drop anchor points with your mouse and it will try to auto find the border and "snap to". Pretty slick but doesn't work perfectly when I played with it. And requires a separate "invert" option to handle all scenarios. http://fotoflexer.com/demos.php 2. Clipping Magic: This one is very cool and surprisingly accurate. You basically paint rough green lines over the stuff you want to keep and red lines over the stuff you want to cut out and a live preview lets you see the result. https://clippingmagic.com/tutorials/basics I am not asking for anyone to give me any code whatsoever, just curious, do you think both of these types of things are doable strictly using PHP (using GD and maybe some other custom PHP classes floating around the web)? Are you able to tell what they both use now? Actually looks like Smart Scissors uses Flash, but not sure about Clipping Magic. I ideally would make something more like Clipping Magic. I just don't want to start building in PHP if there are things that some of you smarter people on this site can tell I will never be able to accomplish using solely PHP, even if I was the best PHP developer ever. Any info, direction, advice would be greatly appreciated. Thanks!
  3. On this dev url , the blue down "auto scroll" arrow under the headline text uses a simple anchor to jump to a spot on the page (and some javascript to slow down the scroll, but I don't think that matters as far as my question goes). As you can see, I'm also using Skrollr to animate objects and when you scroll down manually, the page kind of 'sticks' when the iMac reaches the top of the page. THAT is where I'd like the "auto scroll" arrow button to jump to and STOP. Right now, it scrolls to that spot, but then keeps going a little further. I've tried putting the anchor element in all different spots, but none get the desired resting place. That got me wondering if you can specify that an anchor scrolls down to a certain scroll position (for example, 300 pixels) rather than to an actual anchor element. In other words, my skrollr code fixes the monitor to the top of the page when the user scrolls 300 pixels. So that is where I need the "auto scroll" down arrow to jump to. Anyone know if this is possible, or have another idea? Thanks!
  4. Wasnt sure whether to put this in Javascript or CSS, sorry... I'm using Skrollr at this dev URL (http://workwave.joomlatest01.mms-dev.com/) to make all the desk items "slide away" NOTE: things are messy currently but you get the gist of what happens (i.e. the clutter moves away and the software on the monitor replaces it) I'm using this "helper" function, found here (https://www.bram.us/2014/01/01/skrollr-css-animations-linked-to-scroll-position/)... var setSkrollr = function($el, data) { for (var i = 0, l = data.length; i < l; i++) { // loop all data entries (scroll positions + css property & value) var d = data[i], // the current data entry px = d[0]; // the scroll position (in pixels) css = d[1]; // the css property + value to set $el.attr('data-' + px, css); } } So the skrollr code for these moving desk items looks like this currently... jQuery(function($) { setSkrollr($('#t3-mainnav'), [[0, 'height: 100px'], [300, 'height: 50px']]); setSkrollr($('#t3-mainnav .container'), [[0, 'top: 25px; height: 100px'], [300, 'top: 0px; height: 50px ']]); setSkrollr($('#filecabinet'), [[0, 'top: -60px; left: 60%; display: block;'], [300, 'top: 280px; left: 200%; display: none']]); setSkrollr($('#calculator'), [[0, 'top:520px; left:0%'], [300, 'top:700px; left:-200%']]); setSkrollr($('#stapler'), [[0, 'top:440px; left:12%'], [300, 'top:700px; left:-200%']]); setSkrollr($('#pens'), [[0, 'top:280px; left:38%;'], [300, 'top:580px; left:-200%; ']]); setSkrollr($('#postits'), [[0, 'top:470px; left:70%; display: block;'], [200, 'top:700px; left:200%; display: none;']]); setSkrollr($('#cup'), [[700, 'top:640px'], [1800, 'top:-500px'] ]); setSkrollr($('#map'), [[0, 'top:530px; left:73%; display: block'], [200, 'top:700px; left:200%; display: none; ']]); setSkrollr($('#calendar'), [[0, 'top:500px; left:22%;display: block'], [300, 'top:740px; left:-200%; ']]); setSkrollr($('#monitor'), [[0, 'display:none'], [100, 'display:block; top: 100%'], [300, 'top:11%; position: fixed'], [700, 'top:11%'], [1600, 'top:-100%'] ]); setSkrollr($('#headline'), [[700, 'top:90px'], [1800, 'top:-400px'] ]); setSkrollr($('#desk'), [[700, 'top:560px'], [1800, 'top:-500px'] ]); setSkrollr($('.toplink'), [[0, 'display:block'], [10, 'display:none']]); skrollr.init({ smoothScrolling: false }); I can change the size of the images based on screen resolution using CSS Media Queries and "scale" to reduce the size of the images as the screen width decreases. But right now things are POSITIONED using that skrollr helper function above and I can't change the positions based on screen resolutions. In other words, whatever position I specify in the helper function is the position always. So I can say start the map 85% from the left and it will always be 85% from the left regardless of screen size. So visually it starts in different spots, i.e. if things are positioned OK on a 1920 monitor, when you go down to a 1024 monitor, things are not ideally positioned. It would be a lot of work, but if I could adjust starting/ending positions in media queries, I could make things look perfect at pretty much every resolution. Anyone know if this is possible? I'm new to Skrollr so may just be missing something. Or if anyone has other ideas on how to do this animation easier/more efficiently, please let me know. Thanks!
  5. Thank you both for the suggestions. The adjustments change weekly, but not every request or anything, so I will definitely look into storing them in a table since that seems to be the best route. I will also read up on TEMPORARY tables whether I use them or not. Thanks again!
  6. Thanks for reply.... a. There are around 900 artists b. Every artist will have a value, which can be 0 (i.e. zero would not adjust the original rank at all) c. Not exactly. I don't put the "adjusted" ranks into a table or replace anything. Essentially, I set the original rank each week which does get stored in a database. Each week, adjusted ranks are calculated on the fly and sometimes used, sometimes not. There's no real reason to keep the adjusted ranks in a table since they change quite a bit, and from week to week. It's hard to explain so let me use an easier to digest similar example since I'm also working on fantasy sports site. A fantasy football site might rank players each week. But sometimes scoring is based on PPR (points per reception) so rankings for PPR might be a little different than standard scoring. And most commonly, PPR adjustments would work off of year-to-date statistics, specifically "number of receptions". So each week, the rankings might load based on standard scoring and then if the user clicks "PPR Scoring", the page would look at all reception statistics and create an adjustment to the rankings based off of those stats. So each player would have adjustment number. Then when displaying the rankings again using PPR scoring, the code would re-rank according to the "ppr adjustment". That sounded good in my head, but I may have just confused things ever more. If I have, I apologize. Hopefully it kind of makes sense. If anything, I'd love to hear more about creating a TEMPORARY table. That thought never crossed my mind. Is this common? If I ever ending up getting a lot of traffic accessing the artists ranking page, could it be bad to have a table created and then subsequently (i assume) deleted every single time the page is accessed?
  7. I have these two tables... schedule (gameid, homeid, awayid, weekno, seasonno) teams (teamid, location, nickname) This mysql query below gets me schedule info for ALL 32 teams in an array... $sql = "SELECT h.nickname AS home, a.nickname AS away, h.teamid AS homeid, a.teamid AS awayid, s.weekno FROM schedule s INNER JOIN teams h ON s.homeid = h.teamid LEFT JOIN teams a ON s.awayid = a.teamid WHERE s.seasonno =2014"; $schedule= mysqli_query($connection, $sql); if (!$schedule) { die("Database query failed: " . mysqli_error($connection)); } else { // Placeholder for data $data = array(); while($row = mysqli_fetch_assoc($schedule)) { if ($row['away'] == "") {$row['away']="BYE";} $data[$row['homeid']][$row['weekno']] = $row['away']; $data[$row['awayid']][$row['weekno']] = '@ '.$row['home']; } } However, I only want to get info for one specific team, which is stored in the $teamid variable. This should be very easy, right? I have tried multiple things, including this one below (where I added an AND statement of "AND (h.teamid=$teamid OR a.teamid=$teamid)"), but this one still outputs too much... $sql = "SELECT h.nickname AS home, a.nickname AS away, h.teamid AS homeid, a.teamid AS awayid, s.weekno FROM schedule s INNER JOIN teams h ON s.homeid = h.teamid LEFT JOIN teams a ON s.awayid = a.teamid WHERE s.seasonno =2014 AND (h.teamid=$teamid OR a.teamid=$teamid)"; $schedule= mysqli_query($connection, $sql); if (!$schedule) { die("Database query failed: " . mysqli_error($connection)); } else { // Placeholder for data $data = array(); while($row = mysqli_fetch_assoc($schedule)) { if ($row['away'] == "") {$row['away']="BYE";} $data[$row['homeid']][$row['weekno']] = $row['away']; $data[$row['awayid']][$row['weekno']] = '@ '.$row['home']; } } Below is the array that the above outputs. In a nutshell, all I want is that 1st array ([1]) which has, in this example, the Eagles full schedule. It's not giving me too much else and I guess I could live with it and just ignore the other stuff, but I'd rather be as efficient as possible and only get what I need... Array ( [1] => Array ( [1] => Jaguars [2] => @ Colts [3] => Redskins [4] => @ 49ers [5] => Rams [6] => Giants [7] => BYE [8] => @ Cardinals [9] => @ Texans [10] => Panthers [11] => @ Packers [12] => Titans [13] => @ Cowboys [14] => Seahawks [15] => Cowboys [16] => @ Redskins [17] => @ Giants ) [27] => Array ( [1] => @ Eagles ) [28] => Array ( [2] => Eagles ) [4] => Array ( [3] => @ Eagles [16] => Eagles ) [14] => Array ( [4] => Eagles ) [15] => Array ( [5] => @ Eagles ) [3] => Array ( [6] => @ Eagles [17] => Eagles ) [] => Array ( [7] => @ Eagles ) [16] => Array ( [8] => Eagles ) [25] => Array ( [9] => Eagles ) [11] => Array ( [10] => @ Eagles ) [7] => Array ( [11] => Eagles ) [26] => Array ( [12] => @ Eagles ) [2] => Array ( [13] => Eagles [15] => @ Eagles ) [13] => Array ( [14] => @ Eagles ) )
  8. Say I have a table called artists with these fields (artistid, rank). Then say I have an array called $rankadjustments with a value for each artist (like 1, 7, 3,-3, 5, 9, etc). I am doing a MYSQL query that gets the info from artists table and sorts according to the rank field like this... $sql = "SELECT * FROM artists ORDER BY rank"; Easy enough. But what if I would like to bring that data back sorted by (rank + rankadjustment). For example, if the artist ranked 1st had a rank of "1" from mysql, but had a rankadjustment of "5" from the rankadjustment array, his "true" rank would be "6". Again, rankadjustment is NOT a field in my table, otherwise it would obviously be simple. It's calculated on the fly and stored in an array. FYI, the array has an index with their "artistid". For example, $rankadjustment[341][8] would be the artist with an artistid of "341" has a rank adjustment of 8. Is there a way to do this IN the query itself? It doesn't seem possible but wanted to find out for sure. If not, what is best way to do? I assume... Get the data sorted JUST by rank and put it all into an array, then create a new array that adds rank to rankadjustment and reorder by the "new" rank amount? I guess that wouldn't be too bad but again, wanted to make sure I'm not missing something that would allow me to do it all in the query (or just more efficiently). Thanks!
  9. Fair question . I am working on a web app that is not close to going live and I'm doing a lot of testing. I have lots of records in my testing database all with the same weeknumber (since that's all i needed up to this point) but I recently added a lot of code that not only displays each weeks data, but also SUMS all data over multiple weeks. I can't test how well that works till I have multiple records for each user. And yes, I could duplicate one or a handful manually and test my code, but there are even more convoluted reasons that I won't bore you with that make it ideal for me to have many, if not all, records duplicated. In a nutshell, it's a statistics website with lots of numbers and there will be a lot of SUMming going on, over muyltiple weeks. Once the site is live, I will be adding all the stats every week, but for now, I just need a bunch of data over multiple weeks (whether it's the same or not) to make sure everything will work properly once I start doing that
  10. Is there a way to duplicate all rows in a table AND change one field's value for each new row? For example... TABLE: comments FIELDS: commentid userid comment weeknumber Say there are only 5 comments in there like this (I have MANY rows, but keeping sample size small for example's sake)... 1-17-hello-3 2-41-hey-3 3-18-yo-3 4-67-sup-3 5-12-hola-3 I would like to duplicate them AND make the "weeknumber" = 4, so the table ultimately has 10 rows like this... 1-17-hello-3 2-41-hey-3 3-18-yo-3 4-67-sup-3 5-12-hola-3 1-17-hello-4 2-41-hey-4 3-18-yo-4 4-67-sup-4 5-12-hola-4 Is this doable? Thanks...
  11. Barand, what you wrote is what I need, just didn't need the SUM part of it, only need the CASE (sorry again for my terrible explanation). Thank you so much!
  12. Sorry I'm really having trouble explaining In plain english, I'm saying...I want to bring back a row for EVERY student in the "students" table, regardless of whether they have any entries in the "grades" table or not. But I would like to know if they specifically have a record in the "grades" table for Period 3. So, based on what you wrote, if it would make Period_3==1 if there was a grade for period 3, or Period_3==0 if there was NOT a grade for period 3, then theoretically that would be all I needed bc I could just run that check and know whether that student had a grade for period 3. I apologize if this doesn't clear things up at all. I have a feeling what you wrote is along the right lines of what I need so I will experiement with that and see what happens. Thank you!
  13. Sorry, one more follow-up to this main question... Let's say I don't want to limit my search to this left join (i.e. LEFT JOIN grades g ON s.studentid = g.studentid AND g.period = 3) but would still like to have that information handy (i.e. still know when a student has an existing grade in period 3). I imagine you can do some type of "AS" statement instead of a LEFT JOIN? Something along these lines, which not surprisingly didn't work when i tried SELECT s.studentid , s.lastname , c.classname , g.grade , g.period , (LEFT JOIN grades g ON s.studentid = g.studentid AND g.period = 3) as period_3_exists FROM students s INNER JOIN classes c USING (studentid) ORDER BY s.lastname Then while looping through the results, I can check if period 3 grades exists by looking for ($row['period_3_exists']==1).
  14. Awesome, thanks again for your VERY helpful information!...
×
×
  • 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.