• Web Dev Questions That Don't Need Their Own Thread v4
    5,001 replies, posted
[QUOTE=eternalflamez;40845058]Didn't see the question, will answer it now: First you select the values of each row. [code]SELECT * FROM `table` WHERE `sid`=114[/code] Then per row you'll want to do this (replace 114 by current id in the iteration): [code]SELECT count(sid) FROM `table` WHERE `sid`=114[/code] Maybe you could merge these but I'm not good enough in mysql to do THAT. Maybe someone else can link this together in one complicated query.[/QUOTE] Had to remove lots of things to not make my post very long, so I guess I forgot important things. That's not what I meant (and just for future reference, if you're looking for something on the same table and with the same WHERE, you can just add it with a ',' , so it'd look "SELECT *,count(sid) FROM..."). I'm trying to get everything where sid equals 114 (SELECT * blablabla WHERE sid = 114). Let's call the results ResultsFrom114. Now, ResultsFrom114 has a value from the column 'columnc' that is 'columnthatIwantvalue'. I'd like to, somehow, get 'columnthatIwantvalue', and count how many times does it appear in 'columnc'. ---- Seems like I finally know how to do it... [code]SELECT *, (SELECT count(sid) FROM `skins` WHERE `uid`= (SELECT `uid` FROM `skins` WHERE `sid`= 1) ) AS `counted` FROM `skins` WHERE `sid`= 1[/code] I'm pretty sure there's a complicated query somewhere that would get `uid` without having to do a third select... Ah welp. Meanwhile, it works :v:
I'm just getting started with web programming and am trying to get a stationary background in my stylesheet. Im trying to use the form: html { background-image: url(place url here) no-repeat center fixed; } but it's not working. What's the best way to do this?
[QUOTE=skzerk;40847144]I'm just getting started with web programming and am trying to get a stationary background in my stylesheet. Im trying to use the form: html { background-image: url(place url here) no-repeat center fixed; } but it's not working. What's the best way to do this?[/QUOTE] background-image specifies the image, while all the other things you added are other characteristics about that background. Just remove the [B]-image[/B] and it should work
[QUOTE=Coment;40847230]background-image specifies the image, while all the other things you added are other characteristics about that background. Just remove the [B]-image[/B] and it should work[/QUOTE] Thanks!
What is a good shopping cart software that everyone uses?
[QUOTE=triscuit6264;40875462]What is a good shopping cart software that everyone uses?[/QUOTE] I heard some people say that Shopify is nice. [editline]Later[/editline] I found a comparison of some. You could consider [URL="http://shopping-cart-review.toptenreviews.com/"]this[/URL]?
I'm trying to get rid of the white borders on the sides of my navigation bar, but I can't seem to get it. [T]http://puu.sh/372pu.png[/T] HTML: [code]<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="css/home.css"/> <link rel="icon" href="img/favicon.ico"/> <script type="text/javascript" src="js/script.js"></script> <script type="text/javascript" src="js/home.js"></script> </head> <body> <!-- Navigation --> <div id="navBar"> <div class="attached"> <div class="lambda" onClick="void(0);"> <span> <a href="home.html">uLambda</a> </span> </div> <ul class="right"> <li><a href="about.html">About Us</a></li> <li><a href="soft.html">Software</a></li> <li><a href="contact.html">Contact</a></li> </ul> </div> </div> <!-- End Navigation --> </body> </html>[/code] CSS:[code] @charset "utf-8"; @import url(http://fonts.googleapis.com/css?family=Lato:300,400); @import url(http://fonts.googleapis.com/css?family=Montserrat); * { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box; -webkit-transition: all 0.2s; -moz-transition: all 0.2s; -ms-transition: all 0.2s; transition: all 0.2s; } body { background: white; font-family: Montserrat, sans-serif; font-weight: normal; font-style: normal; font-size: 14px; line-height: 1; color: #222222; position: relative; -webkit-font-smoothing: antialiased; } /* Misc */ ul { list-style-type: none; } div { display: block; } /* Links */ a img { border: none; } a { color: inherit; text-decoration: none; line-height: inherit; } a:hover { color: #2795b6; } a:focus { color: #2795b6; } /* Nav */ #navBar { z-index: 9003; background-color: #111; width: 100% auto; height: 50px; margin: 0; padding: 0; } #navBar .lambda { float: left; position: fixed; vertical-align: middle; line-height: 50px; font-size: 18px; font-weight: 900; color: #FFF; } #navBar .attached { padding: 0 15px; width: 100%; } #navBar ul { position: fixed; } #navBar .right { float: right; position: relative; } #navBar .right li { vertical-align: middle; display: inline; font-size: 18px; padding-right: 10px; font-weight: 850; color: #FFF; }[/code]
I've gone through the Javascript section of Codecademy and I'm working on the PHP part now (already know HTML & CSS and I like to think I'm good at design so I ignored the other sections). I've found that Codecademy doesn't give particularly good examples or ways to use what I've been taught in the real world, and I'm wondering where to go from here. What do I do? Where do I look for more help? I'm sorta at a dead end. [editline]3rd June 2013[/editline] oh and before someone says "learn ruby/rails" I'm going to do things with PHP first and then move on to Ruby - using it primarly - it seems stupid to not bother learning the most popular serverside language imo
[QUOTE=Datzy;40881224]I'm trying to get rid of the white borders on the sides of my navigation bar, but I can't seem to get it. [T]http://puu.sh/372pu.png[/T] --codesnip-- [/QUOTE] [code] body { margin: 0; } [/code] [url]http://jsfiddle.net/fHq2X/[/url]
[QUOTE=deadeye536;40883007][code] body { margin: 0; } [/code] [url]http://jsfiddle.net/fHq2X/[/url][/QUOTE] Thank you. I love you.
[QUOTE=zerosix;40881602]I've gone through the Javascript section of Codecademy and I'm working on the PHP part now (already know HTML & CSS and I like to think I'm good at design so I ignored the other sections). I've found that Codecademy doesn't give particularly good examples or ways to use what I've been taught in the real world, and I'm wondering where to go from here. What do I do? Where do I look for more help? I'm sorta at a dead end. [editline]3rd June 2013[/editline] oh and before someone says "learn ruby/rails" I'm going to do things with PHP first and then move on to Ruby - using it primarly - it seems stupid to not bother learning the most popular serverside language imo[/QUOTE] As much as I love Codecademy, I don't really believe in "tutorials" anymore. As long as one is intrested in learning, having fun while coding and have something to develop, the only thing you need in order to learn PHP is: [URL="http://php.net/manual/en/"]The PHP Manual[/URL], Google and your favourite editor software! A web-server with PHP and MySQL installed could also be useful! :v:
[QUOTE=Datzy;40883057]Thank you. I love you.[/QUOTE] You can use simply use [code] * { margin: 0; padding: 0; } [/code] to get rid of all those small problems at once. It's a little reset, and it's all I'm using. Using it for every project, even when I'm just testing out stuff :P
[QUOTE=Svenskunganka;40885846]As much as I love Codecademy, I don't really believe in "tutorials" anymore. As long as one is intrested in learning, having fun while coding and have something to develop, the only thing you need in order to learn PHP is: [URL="http://php.net/manual/en/"]The PHP Manual[/URL], Google and your favourite editor software! A web-server with PHP and MySQL installed could also be useful! :v:[/QUOTE] Yeah Codecademy was a nice introduction but it's not really taught me much other than the absolute basics. I guess I'll just try making a basic website with an email form or a file uploader or something that'll test me.
[html]<div style="background:black; a{color:white;}"><a href="http://google.com">Link</a></div>[/html] If for some reason I do not have the capacity to modify the style= attribute of the anchor, it seems like it'd be really fuckin' useful to be able to do something like the above (where the div has an inline specification making all included anchors white). Otherwise I have to run off and write an actual stylesheet. This seems real fuckin' useful. It's not possible is it?
It doesn't really work that way. You don't have to actually make a stylesheat. In the head you could just place [code] <style type="text/css"> a { color: white; } </style> [/code] [editline]4th June 2013[/editline] I have a question about sql. Say I have this table: [table="width: 500, class: grid"] [tr] [td]id[/td] [td]product_id[/td] [td]property_id[/td] [/tr] [tr] [td]1[/td] [td]1[/td] [td]1[/td] [/tr] [tr] [td]2[/td] [td]1[/td] [td]2[/td] [/tr] [tr] [td]3[/td] [td]2[/td] [td]2[/td] [/tr] [/table] If I want to get a single `id` where, in seperate rows, `product_id`=1 and `property_id`=1 or 2? So that it outputs: [table="width: 50, class: outer_border"] [tr] [td]id[/td] [/tr] [tr] [td]1[/td] [/tr] [/table] Because in one row it has property_id=1 and on one row property_id=2 and on both, product_id=1. Hope this makes sense.
[QUOTE=eternalflamez;40896382]It doesn't really work that way. You don't have to actually make a stylesheat. In the head you could just place [code] <style type="text/css"> a { color: white; } </style> [/code] [editline]4th June 2013[/editline] I have a question about sql. Say I have this table: [table="width: 500, class: grid"] [tr] [td]id[/td] [td]product_id[/td] [td]property_id[/td] [/tr] [tr] [td]1[/td] [td]1[/td] [td]1[/td] [/tr] [tr] [td]2[/td] [td]1[/td] [td]2[/td] [/tr] [tr] [td]3[/td] [td]2[/td] [td]2[/td] [/tr] [/table] If I want to get a single `id` where, in seperate rows, `product_id`=1 and `property_id`=1 or 2? So that it outputs: [table="width: 50, class: outer_border"] [tr] [td]id[/td] [/tr] [tr] [td]1[/td] [/tr] [/table] Because in one row it has property_id=1 and on one row property_id=2 and on both, product_id=1. Hope this makes sense.[/QUOTE] [PHP]SELECT `id` FROM `table` WHERE `product_id` = '1' AND (`property_id` = '1' OR `property_id` = '2'); [/PHP] If you only want one value returned, add LIMIT 1 after the closing ")" in the SQL.
[QUOTE=Elecbullet;40895507][html]<div style="background:black; a{color:white;}"><a href="http://google.com">Link</a></div>[/html] If for some reason I do not have the capacity to modify the style= attribute of the anchor, it seems like it'd be really fuckin' useful to be able to do something like the above (where the div has an inline specification making all included anchors white). Otherwise I have to run off and write an actual stylesheet. This seems real fuckin' useful. It's not possible is it?[/QUOTE] Jquery. Specially [url=http://api.jquery.com/css/]this[/url]
I'm actually thinking about this from the perspective of a wiki, which is a kind of site where you can modify lots of inline styles and stuff, but don't always have a lot of access to sitewide CSS/JS. [html]div.blackbg { background:black; a { color:white; } }[/html] Wouldn't it make perfect sense for CSS to include facilities like that? Rather than a declaration for "div.blackbg" and a separate declaration for "div.blackbg a" you could put them one inside the other. It's more useful when you think of it in terms of my previous example.
[QUOTE=Svenskunganka;40897146][PHP]SELECT `id` FROM `table` WHERE `product_id` = '1' AND (`property_id` = '1' OR `property_id` = '2'); [/PHP] If you only want one value returned, add LIMIT 1 after the closing ")" in the SQL.[/QUOTE] I actually want to get the id where there is 2 rows with that id, with one having a property_id of 1 and one with a property_id of 2. If I would limit, and the first row, where `property_id`=1, isn't there, it would still return a row with id=1, because it doesn't explicitively require both values to be true, and then I wouldn't be able to tell wether or not there was 1 row found, 2 rows found or 3 rows found. Atm I fixed this by using your query, and also selecting a count(`id`) and then checking in the php wether or not the count is the same as the amount of id's I gave in. I was just wondering if this would be possible in sql. [editline]4th June 2013[/editline] [QUOTE=Elecbullet;40897166]I'm actually thinking about this from the perspective of a wiki, which is a kind of site where you can modify lots of inline styles and stuff, but don't always have a lot of access to sitewide CSS/JS. //html removed to reduce lengthy post size Wouldn't it make perfect sense for CSS to include facilities like that? Rather than a declaration for "div.blackbg" and a separate declaration for "div.blackbg a" you could put them one inside the other. It's more useful when you think of it in terms of my previous example.[/QUOTE] Css sortof has this: [html] div.blackbg { background:black; } div.blackbg a { color:white; } [/html] EDIT: Oh, didn't seem to read that right. Nvm then.
[QUOTE=eternalflamez;40897234]I actually want to get the id where there is 2 rows with that id, with one having a property_id of 1 and one with a property_id of 2. If I would limit, and the first row, where `property_id`=1, isn't there, it would still return a row with id=1, because it doesn't explicitively require both values to be true, and then I wouldn't be able to tell wether or not there was 1 row found, 2 rows found or 3 rows found. Atm I fixed this by using your query, and also selecting a count(`id`) and then checking in the php wether or not the count is the same as the amount of id's I gave in. I was just wondering if this would be possible in sql. [editline]4th June 2013[/editline] Css sortof has this: [html] div.blackbg { background:black; } div.blackbg a { color:white; } [/html] EDIT: Oh, didn't seem to read that right. Nvm then.[/QUOTE] Simply remove the two "( )" from the SQL completely.
That didn't really seem to work when there were more than 2 :v: Anyway thanks to your original suggestion I got it to work completely on sql: [code] SELECT `id` , COUNT( `id` ) AS `count` FROM `table` WHERE `product_id` =1 AND `property_id` = 1 OR `property_id` = 2 OR `property_id` = 3 GROUP BY `id` HAVING `count`=3 [/code] Thanks.
[QUOTE=eternalflamez;40897463]That didn't really seem to work when there were more than 2 :v: Anyway thanks to your original suggestion I got it to work completely on sql: [code] SELECT `id` , COUNT( `id` ) AS `count` FROM `table` WHERE `product_id` =1 AND `property_id` = 1 OR `property_id` = 2 OR `property_id` = 3 GROUP BY `id` HAVING `count`=3 [/code] Thanks.[/QUOTE] Where you find yourself having to use multiple ORs, it's often nicer just to use IN(). [CODE] SELECT `id`, COUNT( `id`) AS `count` FROM `table` WHERE `product_id` = 1 AND `property_id` IN(1,2,3) GROUP BY `id` HAVING `count`=3 [/CODE]
I'm already familiar with HTML and CSS, but I want to learn PHP too now, is there any specific website where I can learn PHP from?
Pointing [URL="http://facepunch.com/showthread.php?t=1250244&p=40885846&viewfull=1#post40885846"]here[/URL] since he's right. I guess people are using [URL="http://www.codecademy.com/#!/exercises/0"]codeacedemy[/URL] to start on the basics. [editline]5th June 2013[/editline] [url]http://www.codecademy.com/tracks/php[/url] more specifically, for php.
I'm trying to do a psuedo thing with the menu of the page I'm working on. I can only find how to set the background color when hovering, but i want the font to change color, not the background. I'm using this in my css file: [CODE] menu.hover { font-color: #FFFFFF; } [/CODE] But nothing is happening. What is the correct way to do this?
[QUOTE=skzerk;40916470] [CODE] V--if it's a class, it needs to be ".menu"; if it's a div, "#menu" menu:hover { color: #FFFFFF; } [/CODE] [/QUOTE]
[QUOTE=Coment;40916677][/QUOTE] It's a div in the html, and even with the changes that you said, It's still not working is there something i have to do in the html section? [CODE] <div id=menu> <p><a href=jack.html style="text-decoration: none">Jack Jones</a></p> <p><a href=about.html style="text-decoration: none">About Me</a></P> <p><a href=work.html style="text-decoration: none">Some Work<br>I've Done </a></p> <p><a href=contact.html style="text-decoration: none">Contact Me</a></p> </div> current css: menu:hover { color: #FF0000; } [/CODE]
He means that if it's class="menu" it should be ".menu:hover". When it's an id it should be "#menu:hover". Given your html it should be: [html] #menu a:hover { color: #FF0000; } [/html] (Have to target the <a> tag itself, I think. Just going #menu doesn't work in jsfiddle) Also, no quotes around the id and the href? What's up with that?
What eternalflamez is trying to say is, change your current code to this: [PHP] <div id="menu"> <p><a href="jack.html" style="text-decoration: none">Jack Jones</a></p> <p><a href="about.html" style="text-decoration: none">About Me</a></P> <p><a href="work.html" style="text-decoration: none">Some Work<br>I've Done </a></p> <p><a href="contact.html" style="text-decoration: none">Contact Me</a></p> </div> #menu a:hover { color: #FF0000; } [/PHP] Note the double-quote wrappings around the id="menu" and href's.
I made a CMS on xampp - switched it over to a host get errors, maybe you can help me Facepunch. Error when landing on login page: Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /panel/login.php:5) in /panel/functions/functions.php on line 2 Error when logging in: Warning: Cannot modify header information - headers already sent by (output started at /panel/login.php:5) in l/login.php on line 37 Login.php [PHP] <head> <link rel="stylesheet" type="text/css" href="style/style.css"> </head> <?php include 'functions/functions.php'; if(isset($_POST['login'])) { $username = sanitize($_POST['username']); $password = sanitize($_POST['password']); if (empty($username) === true || empty($password) === true) { $errors[] = 'You need to enter a username and password.'; $color = 'red'; } else if (username_exists($username) === false) { $errors[] = 'Invalid Username and Password combination'; $color = 'red'; } else if (login($username, $password) === false){ $errors[] = 'Invalid Login.'; $color = 'red'; } else { $login = login($username, $password); $_SESSION['id'] = $login; $date = date('Y-m-d H:i:s'); $updateLogged = "UPDATE `user` SET `lastlogged` = '$date' WHERE `id` = '".$_SESSION['id']."'"; mysql_query($updateLogged) or mysql_error(); $insertLog = "INSERT INTO `logs` ( `user` ,`action`, `date`) VALUES ('$user_data[username]', Logged In', '$date')"; mysql_query($insertLog) or mysql_error(); header('Location: index.php'); } } ?> <div class='login'> <div class='box'> <div class='title'> LOGIN </div> <div class='content'> <form action="login.php" method="post"> <?php echo output_errors($errors, $color);?> <div class='inputbox'> <label>USERNAME:</label><input type="text" name="username" class="inputfields"> </div> <div class='inputbox'> <label>PASSWORD:</label><input type="password" name="password" class="inputfields"> </div> <div class='inputbox'> <input type="submit" name="login" value="Login!" class="button"> </div> <div class='inputbox'> </div> </form> </div> </div> </div> [/PHP] Functions.php [PHP] <?php session_start(); $connect_error = 'Sorry we are experience connection problems.'; mysql_connect('localhost', '****', '***') or die ($connect_error); mysql_select_db('*****') or die ($connect_error); $errors = array(); $rank = array(); $color = 'none'; $url = ''; $broot = 'images/rares/big/'; $sroot = 'images/rares/small/'; error_reporting(E_ALL ^ E_NOTICE ^ E_STRICT); function sanitize($data) { $data = trim($data); $data = strip_tags($data); return mysql_real_escape_string($data); } function output_errors($errors, $color) { $output = array(); foreach($errors as $error) { $output[] = '<li>' . $error . '</li>'; } return '<div class="' . $color . '">' . implode('', $output) . '</div>'; } function output_rank($ranks) { $rankoutput = array(); $tring = ""; foreach($ranks as $rank) { if ($rank == 0) { $rank = 0; } else if ($rank == 1) { $rank = 1; } $tring = $tring . strval($rank); } return $tring; } function username_exists($username) { $query = mysql_query("SELECT COUNT(`id`) FROM `user` WHERE `username` = '$username'"); return (mysql_result($query, 0) == 1) ? true : false; } function badge_exists($img) { $query = mysql_query("SELECT COUNT(`id`) FROM `badges` WHERE `img` = '$img'"); return (mysql_result($query, 0) == 1) ? true : false; } function user_id_from_username($username){ $username = sanitize($username); return mysql_result(mysql_query("SELECT `id` FROM `user` WHERE `username` = '$username'"), 0, 'id'); } function login($username, $password){ $user_id = user_id_from_username($username); $username = sanitize($username); $password = sha1($password); return (mysql_result(mysql_query("SELECT COUNT(`id`) from `user` WHERE `username` = '$username' AND `password` = '$password'"), 0) == 1) ? $user_id : false; } function logged_in(){ return(isset($_SESSION['id'])) ? true : false; } function protect_page() { if(logged_In() === false) { header('Location: login.php'); exit(); } } if (logged_in() === true) { $session_user_id = $_SESSION['id']; $user_data = user_data($session_user_id, 'username', 'password', 'email', 'habboonname', 'rank', 'lastlogged'); } function user_data($id) { $data = array(); $user_id = (int)$id; $func_num_args = func_num_args(); $func_get_args = func_get_args(); if ($func_num_args > 1) { unset($func_get_args[0]); $fields = '`' . implode('`, `', $func_get_args) . '`'; $data = mysql_fetch_assoc(mysql_query("SELECT $fields FROM `user` WHERE `id` = $id")); return $data; } } function url($url) { if (empty($url) === true) { $url = 'welcome'; } else { $url = $url; } } ?> [/PHP]
Sorry, you need to Log In to post a reply to this thread.