Jump to content

aspacecodyssey

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Everything posted by aspacecodyssey

  1. Thanks for the reply. I wound up figuring it out! It was a nested SELECt as I suspected. I had never done one before. This was the solution: SELECT * FROM ( SELECT images.image, images.artist, artists.id, artists.firstname, artists.lastname FROM images JOIN artists ON images.artist=artists.id ORDER BY RAND() ) AS T GROUP BY id ORDER BY lastname This grabs 1 random row for each artist in the images table, then sorts the result by artist's lastname.
  2. It seems like I need to select the entire table of images, i.e. all images, then sort them (ORDER BY), *then* GROUP BY. Maybe a nested list?
  3. Server version: 5.1.37 I have 2 tables: 'artists' and 'images'. They are set up as follows: artists: id, name images: id, image, artist The 'artist' column in the 'images' table corresponds to the 'id' column from the 'artists' table. So, some sample data from 'images': 1 file1.jpg 4 2 file2.jpg 5 3 file3.jpg 4 4 file4.jpg 6 5 file5.jpg 6 6 file6.jpg 5 7 file7.jpg 6 I would like to SELECT 1 random row from the images table using GROUP BY (I think) such that 1 random image for each artist is selected. If there are 30 artists, 30 rows should return, random each time. My attempt was: SELECT images.image, images.artist, artists.id FROM images JOIN artists ON images.artist=artists.id GROUP BY artists.id ORDER BY RAND() But this is simply selecting the first image (by id) for each artist and ordering randomly *after* the fact. Any ideas?
  4. Just looking for some feedback. I do mostly front-end web design (I'm fairly well versed in PHP/SQL, but design is my forté) as well as standard print/branding stuff. I've been going with this for a little while, maybe some people will have some fresh ideas. http://aspacecodyssey.com/
  5. Pastebin: http://aspacecodyssey.pastebin.com/iPRJUWcP
  6. Sorry, code block: var list = new Array(); list[0] = "likes this^enjoys this"; list[1] = "Like this item^Enjoy this item"; list[2] = ">Like<^>Enjoy<"; <br />list[3] = ">Unlike<^>Unenjoy<"; <br />list[4] = "You like this.^You enjoy this."; <br />list[5] = "> like this.^> enjoy this."; list[6] = "People who like this^People who enjoy this"; var j, k, find, item, page, repl; for (var i=0; i<list> item = list[i].split("^"); find = item[0]; repl = item[1]; page = document.body.innerHTML; while (page.indexOf(find) >= 0) { var j = page.indexOf(find); var k = find.length; page = page.substr(0,j) + repl + page.substr(j+k); document.body.innerHTML = page; }
  7. I've been trying to create a greasemonkey script to change the text of the "like/unlike" (and applicable) text on facebook and I'm stuck. The script below works only on a hard refresh, but since facebook is ajax-heavy, it fails as soon as you start moving around: var list = new Array(); list[0] = "likes this^enjoys this"; list[1] = "Like this item^Enjoy this item"; list[2] = ">Like<^>Enjoy<";<br />list[3] = ">Unlike<^>Unenjoy<";<br />list[4] = "You like this.^You enjoy this.";<br />list[5] = "> like this.^> enjoy this."; list[6] = "People who like this^People who enjoy this"; var j, k, find, item, page, repl; for (var i=0; i<list> item = list.split("^"); find = item[0]; repl = item[1]; page = document.body.innerHTML; while (page.indexOf(find) >= 0) { var j = page.indexOf(find); var k = find.length; page = page.substr(0,j) + repl + page.substr(j+k); document.body.innerHTML = page; } } Any ideas?
  8. Thanks. It appears that would help me count items in a particular subcategory or to display the first of each -- but how would I set it to show the title of each subcategory, followed by all the items in that subcategory?
  9. I'm making a website for a restaurant and putting their menu into a MySQL database. Here's my table setup: id title details price category subcategory region beertype So here's some example data: 6 Lunch Item 1 This is a test of Lunch Item #1. 14.75 lunch Salads 7 Dinner Iten 1 This is a test of Dinner Item 1. 16.00 dinner Quesadillas 8 Brunch Item 1 This is a test of Brunch Item 1. 6.87 brunch Eggs 13 Beerb 1 4.75 beerb CO hardcider Each "category" is given its own page. What I want to do is pull and display the data (PHP) so that it's grouped by "subcategory", like so: Salads -------- Salad 1 -- Price Salad 2 -- Price ..etc. Appetizers ------- Appetizer 1 -- Price Appetizer 2 -- Price ..etc. Any way to do that? Array, perhaps?
  10. I'm making a website for a restaurant and putting their menu into a MySQL database. Here's my table setup: id title details price category subcategory region beertype So here's some example data: 6 Lunch Item 1 This is a test of Lunch Item #1. 14.75 lunch Salads 7 Dinner Iten 1 This is a test of Dinner Item 1. 16.00 dinner Quesadillas 8 Brunch Item 1 This is a test of Brunch Item 1. 6.87 brunch Eggs 13 Beerb 1 4.75 beerb CO hardcider Each "category" is given its own page. What I want to do is pull and display the data (PHP) so that it's grouped by "subcategory", like so: Salads -------- Salad 1 -- Price Salad 2 -- Price ..etc. Appetizers ------- Appetizer 1 -- Price Appetizer 2 -- Price ..etc. Any way to do that? Array, perhaps?
  11. Sorry, I'm not familiar with that -- is there any solution on my end, or would this be all GoDaddy? I've been back and forth with their support team, but they keep insisting it's coding related (though I think they may be doing that because they don't provide coding support, and I've shown them about 15 other sites I've made that use exactly the same rewrite code and work properly).
  12. Hi, I'm doing a simple hiding of ".php" from everything (i.e. www.website.com/subpage will mask to www.website.com/subpage.php). I'm using the following Rewrite rules: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php This has worked for me many many times before. Currently, it's set up at this website: http://www.danbarryfilms.com/ But, as you can see by trying http://www.danbarryfilms.com/resume (which should show http://www.danbarryfilms.com/resume.php), it's not working. However, for some odd reason, if you try http://www.danbarryfilms.com/welcome it will redirect to http://www.danbarryfilms.com/welcome.html -- even though there is no rewrite rule concerning .html files, AND even if there is no .htaccess file present on the server. This is a GoDaddy server...I'm not sure if that means anything.
  13. I'm doing a simple, nifty mod_rewrite on this website: http://www.reliabilityplus.net/ For example, This: http://www.reliabilityplus.net/page/General%20Contracting Is actually this: http://www.reliabilityplus.net/pics?page=General%20Contracting And This: http://www.reliabilityplus.net/page/General%20Contracting/Interior%20Home%20Renovation Is actually this: http://www.reliabilityplus.net/pics?page=General%20Contracting&pagesub=Interior%20Home%20Renovation This goes 3 deep (the last being http://www.reliabilityplus.net/page/General%20Contracting/Interior%20Home%20Renovation/Custom%20Chandelier%20Installation with "pagesubsub"), and this is my rule: RewriteRule page/(.*)/(.*)/(.*)/? pics?page=$1&pagesub=$2&pagesubsub=$3 RewriteRule page/(.*)/(.*)/? pics?page=$1&pagesub=$2 RewriteRule page/(.*)/? pics?page=$1 So it's a basic drilldown from most to least -- is there a way (with regex, I imagine) to just make it 1 rule?
  14. $(document).ready(function(){ $("input[type=checkbox]").click(function(){ project = $(this).attr("value").replace(/ /g,'-'); if ($(this).is(":checked")) { $("#" + project).show('fast'); } else if($(this).not(":checked")) { $("#" + project).hide('fast'); } }); });
  15. Got it! $(document).ready( function(){ $("input[name='project']").click(function(){ var project = $("input[name='project']:checked").val().replace(/ /g,'-'); $('#' + project).show(); }); });
  16. Hey there, I've got standard select values in a form, and I'd like them each to show applicably titled div's (based on id) onclick. I don't want to have to specify which div should be shown when which option is chosen; I'd ratehr be able to use a string replace, i.e.: <input type="radio" name="project" value="Asphalt Paving Installation" />Asphalt Paving Installation<br /> <input type="radio" name="project" value="Asphalt Paving Repair or Patch" />Asphalt Paving Repair or Patch<br /> <input type="radio" name="project" value="Asphalt Seal Coating" />Asphalt Seal Coating<br /> <input type="radio" name="project" value="Excavating" />Excavating<br /> <input type="radio" name="project" value="Drainage" />Drainage<br /> <input type="radio" name="project" value="Masonry" />Masonry<br /> <input type="radio" name="project" value="Other" />Other<br /> So instead of basically saying "show this specific <div> if this specific radio button is selected, I'd like to be able to do this: <div id="Asphalt-Paving-Installation" class="hidden"> Stuff here </div> And something like: $(document).ready( function(){ $("input[name='project']").click(function(){ var project = $("input[name='project']:checked"); project.val( project.val().replace(' ','-') ); $("#"project.val()).show(); }); }); This way the div and the radio value can be the same (with the xception of the space/dash). Any ideas?
  17. I'm already using it. The images still slow down to a near-complete stop (I would guess they never actually make a full stop) and then speed up at the same pace. I'm looking to make the sped fluid throughout.
  18. Hey, I'm using the JQuery cycle plugin (http://malsup.com/jquery/cycle/) and I have images set to auto-scroll horizontally. The plugin automatically eases the slides (I've tried turning easing off), and I'm wondering if anyone knows of a way to get them to just continually move horizontally (without slowing/speeding up). I'm using it to create the illusion of moving fish in a background image: http://blazonmarketing.net/projects/mspd Any help would be appreciated.
  19. I have a MySQL table set up that stores image paths and descriptions. It has 30 or so rows in it (more are added periodically) -- when displaying them, I'd like to separate them so that a <div> wraps every 9 rows, i.e. <div class="imagegroup"> <a href="image1big.jpg"><img src="image1sm.jpg" /></a> <a href="image2big.jpg"><img src="image2sm.jpg" /></a> <a href="image3big.jpg"><img src="image3sm.jpg" /></a> <a href="image4big.jpg"><img src="image4sm.jpg" /></a> <a href="image5big.jpg"><img src="image5sm.jpg" /></a> <a href="image6big.jpg"><img src="image6sm.jpg" /></a> <a href="image7big.jpg"><img src="image7sm.jpg" /></a> <a href="image8big.jpg"><img src="image8sm.jpg" /></a> <a href="image9big.jpg"><img src="image9sm.jpg" /></a> </div> <div class="imagegroup"> <a href="image10big.jpg"><img src="image10sm.jpg" /></a> <a href="image11big.jpg"><img src="image11sm.jpg" /></a> <a href="image12big.jpg"><img src="image12sm.jpg" /></a> <a href="image13big.jpg"><img src="image13sm.jpg" /></a> <a href="image14big.jpg"><img src="image14sm.jpg" /></a> <a href="image15big.jpg"><img src="image15sm.jpg" /></a> <a href="image16big.jpg"><img src="image16sm.jpg" /></a> <a href="image17big.jpg"><img src="image17sm.jpg" /></a> <a href="image18big.jpg"><img src="image18sm.jpg" /></a> </div> ...and so on. Been toying with it for a while, can't figure it out. Anyone have an idea?
  20. Works like a charm. Test it out, it's quite fun: http://www.topzipco.com/ U: test P: passwd123 "Design Your Own Bag" > "Save Bag" It's still not working on the server I need it to work on, but the code itself works. Thanks!
  21. Huh -- yeah, it does work actually. It's the host I'm using -- I tested it on a different server, and it worked. Damn. Wonder if the original code will work there, too. Okay, so follow-up. It does seem like it should be a simple task to use an array instead of a list of images, but how would I do that? I'm really overthinking it.
  22. I tried it, first testing without trying to implement the array on top of it, i.e.: <?php //function merge_png() takes two or more URLs or paths to PNG files as arguments, and merges the PNGs function merge_png() { //check and store arguments if (func_num_args() < 2) { trigger_error('Wrong parameter count for merge_png()', E_USER_ERROR); return false; } $args = func_get_args(); //set image width and height $w = 455; $h = 455; //create blank, fully transparent canvas $im = imagecreatetruecolor($w, $h); imagesavealpha($im, true); $trans_color = imagecolorallocatealpha($im, 0, 0, 0, 127); imagefill($im, 0, 0, $trans_color); //merge PNGs foreach($args as $url) { $dest_im = imagecreatefrompng(str_replace(' ', '%20', $url)); imagecopy($im, $dest_im, 0, 0, 0, 0, $w, $h); } //output final image header('Content-type: image/png'); imagepng($im); imagedestroy($im); return true; } //usage //image credits goes to the creator merge_png( 'http://www.topzipco.com/images/design/patterns/10586s/fp/pattern00-11.png', 'http://www.topzipco.com/images/design/patterns/10586s/ht/pattern00-115.png', 'http://www.topzipco.com/images/design/patterns/10586s/lt/pattern00-1795.png', 'http://www.topzipco.com/images/design/patterns/10586s/p/pattern00-469.png', 'http://www.topzipco.com/images/design/lines/10586s.png' ); ?> I'm so lost here. This seems like it should work.
×
×
  • 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.