• Web Development Questions That Don't Need Their Own Thread v2
    3,079 replies, posted
[url]http://stackoverflow.com/questions/1572110/how-to-calculate-age-in-years-based-on-date-of-birth-and-getdate[/url] [img]http://dl.dropbox.com/u/5483751/Photos/2011-11-27_1444.png[/img]
How do I add text efore the output of the script? So that it says like "Ending in" before the X days X hours Xminutes [code]<font size="4"><div align="center" id="countbox1"><script type="text/javascript"> // NOTE: the month entered must be one less than current month. ie; 0=January, 11=December // NOTE: the hour is in 24 hour format. 0=12am, 15=3pm etc // format: dateFuture1 = new Date(year,month-1,day,hour,min,sec) // example: dateFuture1 = new Date(2003,03,26,14,15,00) = April 26, 2003 - 2:15:00 pm dateFuture1 = new Date(2011,11,03,15,0,0); // TESTING: comment out the line below to print out the "dateFuture" for testing purposes //document.write(dateFuture +"<br />"); function GetCount(ddate,iid){ dateNow = new Date(); //grab current date amount = ddate.getTime() - dateNow.getTime(); //calc milliseconds between dates delete dateNow; // if time is already past if(amount < 0){ document.getElementById(iid).innerHTML="Now!"; } // else date is still good else{ days=0;hours=0;mins=0;secs=0;out=""; ms = (""+((amount%1000)+1000)).substr(1,3); amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs days=Math.floor(amount/86400);//days amount=amount%86400; hours=Math.floor(amount/3600);//hours amount=amount%3600; minutes=Math.floor(amount/60);//minutes amount=amount%60; secs=Math.floor(amount);//seconds if(days != 0){out += days +" "+((days==1)?"day":"days")+", ";} if(hours != 0){out += hours +" "+((hours==1)?"hour":"hours")+", ";} out += mins +" "+((mins==1)?"min":"mins")+", "; out += secs +("."+ms)+" "+((secs==1)?"sec":"secs")+", "; out = out.substr(0,out.length-2); document.getElementById(iid).innerHTML=out; setTimeout(function(){GetCount(ddate,iid)}, 25); } } window.onload=function(){ GetCount(dateFuture1, 'countbox1'); }; </script></div></font>[/code]
[code]out = "Ending in "; // all the processing of out to add the date values[/code]
I'm currently having problems getting this piece of code to execute correctly, it doesn't actually write any data into the table however all of the outputs are correct. The database is connected and when inserting the information without using variables the insert command works correctly. Is there anything wrong with this code? [code] <?php $x = 1001; $SQL = "SELECT * FROM lab2"; $result = mysql_query($SQL); srand($x); $name = $_POST['name']; // DEBUGGING SECTIONS echo $name; echo ' '; echo $x; echo ' '; $username = strval(rand()); echo $username; echo ' '; $password = md5(rand()); echo $password; echo ' '; // THIS PIECE OF CODE HERE DOESN'T WORK mysql_query("INSERT INTO `lab2` (`id`, `catagory`, `name`, `username`, `regnum`, `password`) VALUES ($x, 'guest', $name, $username, $x, $password);") ?> [/code]
Have you actually connected to the database before attempting to retrieve / send data.
[QUOTE=kragmars102;33473622]Have you actually connected to the database before attempting to retrieve / send data.[/QUOTE] He has a select and said only the insert didn't work. He also said the insert works without variables.
try this: [code]mysql_query("INSERT INTO 'lab2' ('id','catagory','name','username','regnum','password') VALUES ('".$x."','guest','".$name."','".$username."','".$x."','".$password."')");[/code]
[QUOTE=Jacko2007;33473551]Is there anything wrong with this code?[/QUOTE] Yes, you're using mysql_ library [img]http://www.facepunch.com/fp/emoot/colbert.gif[/img] You could try inserting quotes around all the values. If it worked without the variables, lack of quotes might be the cause. [php]mysql_query("INSERT INTO `lab2` (`id`, `catagory`, `name`, `username`, `regnum`, `password`) VALUES ('$x', 'guest', '$name', '$username', '$x', '$password');")[/php] If you insist on using mysql_, at least remember to sanitize all variables you're inserting into the sql strings. e: Whoops, forgot to refresh.
srand() with a constant value is not going to give you a random value. You'll get the same value every time on that system. You should seed with the time or something.
[QUOTE=kragmars102;33473650]try this: [code]mysql_query("INSERT INTO 'lab2' ('id','catagory','name','username','regnum','password') VALUES ('".$x."','guest','".$name."','".$username."','".$x."','".$password."')");[/code][/QUOTE] so uh, variables are interpolated in double quotes you know
Does anyone here have any suggestions on what web hosting service is best for small businesses? I've been told GoDaddy is good, but I have heard more than enough horror stories about them. I honestly just need a low-to-medium traffic accessible website that doesn't force me into some soul-binding contract or representation from a free domain. Thanks guys.
[QUOTE=MCPeePants;33475717]Does anyone here have any suggestions on what web hosting service is best for small businesses? I've been told GoDaddy is good, but I have heard more than enough horror stories about them. I honestly just need a low-to-medium traffic accessible website that doesn't force me into some soul-binding contract or representation from a free domain. Thanks guys.[/QUOTE] [url]www.lithiumhosting.com[/url]
can I write in css that the background image must always completely fill the screen? so if it was an 8 by 8 pixel background, it'd stretch across the whole screen regardless of how I resize the page? [editline]28th November 2011[/editline] I tried 'background-size: 100%' but it didn't really work
background-repeat:repeat;
Anyone know of methods in PHP to pick the most vibrant/colourful/interesting image from a bunch of image files? I'm currently choosing the biggest image to thumbnail, but would rather choose the ones with more colour/less black/white combos. There's imagecolorat() and I could simply loop through the pixels (or a few random ones) - but I thought I'd check here to see if anyone's got a better method?
[QUOTE=TehWhale;33477557]background-repeat:repeat;[/QUOTE] but wouldnt that just repeat it? because it's an image as a background and it'd look really weird
wait do you honestly want to stretch a 8x8px background across the whole page? do you know how bad that would look?
well no, not a 8x8, that was just an example but it's a much larger image that is just a tiny bit too small
- Put this right below your body tag. before anything else. [code]<img src="yoururl.gif" class="bg" />[/code] [code]img.bg{ position: absolute; width: 100%; height: 100%; top: 0%; left: 0%; }[/code]
[QUOTE=TehWhale;33477699]wait do you honestly want to stretch a 8x8px background across the whole page? do you know how bad that would look?[/QUOTE] i would imagine that it could look quite nice if applied in a certain fashion you shouldnt be so discerning from good and bad
[QUOTE=Fizzadar;33477637]Anyone know of methods in PHP to pick the most vibrant/colourful/interesting image from a bunch of image files? I'm currently choosing the biggest image to thumbnail, but would rather choose the ones with more colour/less black/white combos. There's imagecolorat() and I could simply loop through the pixels (or a few random ones) - but I thought I'd check here to see if anyone's got a better method?[/QUOTE] How about looking into how people work out the average colour of images? I imagine that'd give you a satisfactory way of ranking their intensity.
[QUOTE=Fizzadar;33477637]Anyone know of methods in PHP to pick the most vibrant/colourful/interesting image from a bunch of image files? I'm currently choosing the biggest image to thumbnail, but would rather choose the ones with more colour/less black/white combos. There's imagecolorat() and I could simply loop through the pixels (or a few random ones) - but I thought I'd check here to see if anyone's got a better method?[/QUOTE] Personally I'd sample pixel colors from a grid over the image. As a rough example: divide the image into 8x8 blocks (or 16x16, or 32x32, whatever), and then sample the pixel in the middle of each block (so you're basically doing a 2d stepped loop over the image's pixels, but you don't act on every single pixel from the thousands in the image); with this data you can work out an average intensity for each thumbnail, throw that in with the thumbnail data and use it as a modifier when selecting the most intense thumbnails. [editline]29th November 2011[/editline] My wording is all over the place, I'm sorta tired and about to head to bed, I'm sorry if I wasn't particularly clear.
[QUOTE=BrQ;33477186]can I write in css that the background image must always completely fill the screen? so if it was an 8 by 8 pixel background, it'd stretch across the whole screen regardless of how I resize the page? [editline]28th November 2011[/editline] I tried 'background-size: 100%' but it didn't really work[/QUOTE] background-size: cover; Won't work in "old" browsers, but works in Firefox/Chrome/Safari/Opera. [QUOTE=StinkyJoe;33482240]Personally I'd sample pixel colors from a grid over the image. As a rough example: divide the image into 8x8 blocks (or 16x16, or 32x32, whatever), and then sample the pixel in the middle of each block (so you're basically doing a 2d stepped loop over the image's pixels, but you don't act on every single pixel from the thousands in the image); with this data you can work out an average intensity for each thumbnail, throw that in with the thumbnail data and use it as a modifier when selecting the most intense thumbnails. [editline]29th November 2011[/editline] My wording is all over the place, I'm sorta tired and about to head to bed, I'm sorry if I wasn't particularly clear.[/QUOTE] One method I saw (and have sitting around), was to loop over every pixel in the image (Ignoring pixels that are too dark, too bright, and greyscale), Convert it to the nearest multiple of 8 ((channel / 8) * 8) and then count how many pixels of each colour there are. Or just downscale the image using something like imagemagick to 1x1 and get the colour of the remaining pixel, much faster but at the same time it only gets an average, instead of the most common colour.
I'm working on learning what I can do with CSS (I'm pretty new to web design and development), and have a quick and probably easy question. How can I make an expanding div tag(functioning as a link) that simply overlaps over other things when it expands it's width in a transition? Like, formatting is optimized so that the div behaves normally when the page is loaded, but when the div is hovered over, it changes it's width and begins overlapping other content areas. I'm sorry if I shouldn't be using divs or the like, but the web design class I'm in is teaching everyone HTML 4(so many tables) on IE7 with no instruction on CSS, so my teacher is useless for this. Diagram if I explained it too horribly [IMG]http://i.imgur.com/4ceD9.png[/IMG]
[QUOTE=ManningQB18;33496613]I'm working on learning what I can do with CSS (I'm pretty new to web design and development), and have a quick and probably easy question. How can I make an expanding div tag(functioning as a link) that simply overlaps over other things when it expands it's width in a transition? Like, formatting is optimized so that the div behaves normally when the page is loaded, but when the div is hovered over, it changes it's width and begins overlapping other content areas. I'm sorry if I shouldn't be using divs or the like, but the web design class I'm in is teaching everyone HTML 4(so many tables) on IE7 with no instruction on CSS, so my teacher is useless for this. Diagram if I explained it too horribly [IMG]http://i.imgur.com/4ceD9.png[/IMG][/QUOTE] maybe :hover or ::hover?
[QUOTE=Ac!dL3ak;33496953]maybe :hover or ::hover?[/QUOTE] Oh no, I can do that, I want to know what the property is to make it OVERLAP. I've been playing with CSS3 stuff for about a week now and the way that it causes the rest of the site to shift makes it impractical.
[QUOTE=ManningQB18;33497120]Oh no, I can do that, I want to know what the property is to make it OVERLAP. I've been playing with CSS3 stuff for about a week now and the way that it causes the rest of the site to shift makes it impractical.[/QUOTE] probably something with relative positioning and z-index
One more little question, what is ::hover? I know of :hover, but not ::hover. I can't google it because google thinks the ':'s are operators.
[QUOTE=ManningQB18;33497904]One more little question, what is ::hover? I know of :hover, but not ::hover. I can't google it because google thinks the ':'s are operators.[/QUOTE] I've never heard of ::hover
[QUOTE=ManningQB18;33497904]One more little question, what is ::hover? I know of :hover, but not ::hover. I can't google it because google thinks the ':'s are operators.[/QUOTE] hmm i thought someone mentioned there was a ::hover a few pages back i guess :hover works just fine anyway
Sorry, you need to Log In to post a reply to this thread.