• Web Dev Questions That Don't Need Their Own Thread v4
    5,001 replies, posted
[QUOTE=gokiyono;40825111]So in PHP there are :: and -> On php.net I see the -> used in the examples, but the :: used in navigation. (I have no idea how I should word that.)[/QUOTE] This is because there are different types of functions within a class. They can be static (which means you can make calls to it and it's contents without instanciating the class first), or non-static, meaning you need to store the class in a variable first. Examples: [php] class MyClass() { //static public static function hello() { echo "Hello"; } public function goodbye() { echo "Goodbye"; } } //Static: MyClass::hello(); //Not static: $myclass = new MyClass(); $myclass->goodbye(); //Will output HelloGoodbye [/php] Note that :: can only call static functions and -> can only call non-static functions. [editline]29th May 2013[/editline] Unless this isn't what you meant. If it's not, take screenshots of examples of such usage and post those here.
[QUOTE=eternalflamez;40825209]This is because there are different types of functions within a class. They can be static (which means you can make calls to it and it's contents without instanciating the class first), or non-static, meaning you need to store the class in a variable first. Examples: [php] class MyClass() { //static public static function hello() { echo "Hello"; } public function goodbye() { echo "Goodbye"; } } //Static: MyClass::hello(); //Not static: $myclass = new MyClass(); $myclass->goodbye(); //Will output HelloGoodbye [/php] Note that :: can only call static functions and -> can only call non-static functions. [editline]29th May 2013[/editline] Unless this isn't what you meant. If it's not, take screenshots of examples of such usage and post those here.[/QUOTE] That was what I asked for. Thank you.
They took the -> from C, because in C if you have a pointer to a struct [code] typedef struct { int a; int b; } some_struct_t; some_struct_t some_variable; [/code] You'd use some_variable->a to get the value of a, which is equal to (*some_variable).a . [editline]29th May 2013[/editline] woo i know stuff
Can any of you guys give me feedback on [url=http://retrooftheweek.net/]my website[/url]?
[QUOTE=Billy2600;40831351]Can any of you guys give me feedback on [url=http://retrooftheweek.net/]my website[/url]?[/QUOTE] bad usage of gradients everywhere. To be honest, I think you're better off making a new theme for that website :/ I didn't realize that the site had a nav bar til i actually read those letters :v: You should add more spaces between them to show that they're separate. Also, align the menu more to the center, between the login bar and the button of the nav bar. It looks really up high. [editline]29th May 2013[/editline] It also feels like that the textbox is trying to blend into the background, maybe you can add a nice border that fits well to differentiate that.
How can I make my loading screen show the viewers steam name and Avatar?
Hey like Samiskewl said how would you make a loading screen say the usernames Steam Name and Avatar but also how would you make it show the current loading Garry's Mod map? Any help is [U]greatly appreciated[/U].
[QUOTE=samiskewl;40834151]How can I make my loading screen show the viewers steam name and Avatar?[/QUOTE] [QUOTE=YourStalker;40834318]Hey like Samiskewl said how would you make a loading screen say the usernames Steam Name and Avatar but also how would you make it show the current loading Garry's Mod map? Any help is [U]greatly appreciated[/U].[/QUOTE] [CODE]//Super quick data retrieving function, provided by 01271 function get_data($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); curl_close($ch); return $data; } //Get the Steam Community ID from provided URL $communityid = $_GET["steamid"]; //Get the Map name from provided URL $mapname = $_GET["mapname"]; //Get response from the Steam API in json format $response = get_data('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=<insert you key here>&steamids=' . $communityid . '&format=json'); //Decode the json response $json = json_decode($response, true); //Get your player's username $nick = $json['response']['players']['0']['personaname']; //Get the URL of your player's avatar //You have 3 options here, avatar returns a 32x32 image, avatarmedium returns a 64x64 image, and avatarfull returns a 184x184 image $avatar = $json['response']['players']['0']['avatar']; $avatarmedium = $json['response']['players']['0']['avatarmedium']; $avatarfull = $json['response']['players']['0']['avatarfull'];[/CODE] In your server config, use [B]sv_loadingurl "yourdomain.com/path/to/file.php?steamid=%s&mapname=%m"[/B] in order to correctly get the user's Community ID and current map. [url]https://developer.valvesoftware.com/wiki/Steam_Web_API[/url]
[QUOTE=Cep.;40834606][CODE]//Super quick data retrieving function, provided by 01271 function get_data($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); curl_close($ch); return $data; } //Get the Steam Community ID from provided URL $communityid = $_GET["steamid"]; //Get the Map name from provided URL $mapname = $_GET["mapname"]; //Get response from the Steam API in json format $response = get_data('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=<insert you key here>&steamids=' . $communityid . '&format=json'); //Decode the json response $json = json_decode($response, true); //Get your player's username $nick = $json['response']['players']['0']['personaname']; //Get the URL of your player's avatar //You have 3 options here, avatar returns a 32x32 image, avatarmedium returns a 64x64 image, and avatarfull returns a 184x184 image $avatar = $json['response']['players']['0']['avatar']; $avatarmedium = $json['response']['players']['0']['avatarmedium']; $avatarfull = $json['response']['players']['0']['avatarfull'];[/CODE] In your server config, use [B]sv_loadingurl "yourdomain.com/path/to/file.php?steamid=%s&mapname=%m"[/B] in order to correctly get the user's Community ID and current map. [url]https://developer.valvesoftware.com/wiki/Steam_Web_API[/url][/QUOTE] So I would just throw that into the loading.php?
[QUOTE=samiskewl;40834730]So I would just throw that into the loading.php?[/QUOTE] Put it inside your php tags, then whenever you want to call a variable inside of your html do [B]<?php echo $variablename; ?>[/B]
How do I rearrange table rows? Javascript, css, doesn't matter as long as there's a way. I have a table and I can change classes/ids on the rows. Ideally I'd want a javascript snippet that will let me output rows with my PHP and order them by class (that is a number). So as an example, I wanna do something like this. <table> <tr class= "120.43"></tr> <tr class= "2300.30"></tr> <tr class= "937.21"></tr> </table> Turning into this <table> <tr class= "120.43"></tr> <tr class= "937.21"></tr> <tr class= "2300.30"></tr> </table> And then the order would change as it was created or on a button or just on script load. Also I won't order it with the php because that'd lose time on content appearing on the page and it's inportant that results start showing up immediately.
[QUOTE=Billy2600;40831351]Can any of you guys give me feedback on [url=http://retrooftheweek.net/]my website[/url]?[/QUOTE] What is with the .loginbar? There are two background-colours and the background-image doesn't look fitting. And I feel like the search box is too small. The social media icons doesn't fit in.
[QUOTE=01271;40836178]How do I rearrange table rows? Javascript, css, doesn't matter as long as there's a way. I have a table and I can change classes/ids on the rows. Ideally I'd want a javascript snippet that will let me output rows with my PHP and order them by class (that is a number). So as an example, I wanna do something like this. <table> <tr class= "120.43"></tr> <tr class= "2300.30"></tr> <tr class= "937.21"></tr> </table> Turning into this <table> <tr class= "120.43"></tr> <tr class= "937.21"></tr> <tr class= "2300.30"></tr> </table> And then the order would change as it was created or on a button or just on script load. Also I won't order it with the php because that'd lose time on content appearing on the page and it's inportant that results start showing up immediately.[/QUOTE] How about this: (Requires jQuery) [url]http://jsfiddle.net/emKkF/[/url] It orders them in the order of the id's given. I could also have it order on the classes themselves (min to max) but this way you wouldn't need to edit the js for each option, just the order of id's you give them in the php.
Is there a way to make a site remember a certain (smart)phone?
Trying to learn using mysqli and I came across this snippet; [php] $sql = <<<SQL SELECT * FROM `users` WHERE `live` = 1 SQL; [/php] Can someone explain what and why "<<<SQL ... SQL" is?
[QUOTE=Cassel;40838509]Trying to learn using mysqli and I came across this snippet; [php] $sql = <<<SQL SELECT * FROM `users` WHERE `live` = 1 SQL; [/php] Can someone explain what and why "<<<SQL ... SQL" is?[/QUOTE] I can tell you what, and vaguely what it does. It is a [URL="http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc"]heredoc[/URL]. I have never really been sure what it actually does. As far as I know it will allow you to write string in multiple lines and not have to worry about quotes. Starting with [I]<<<YourChoiceOfWord[/I] ends with [I]YourChoiceOfWord;[/I] That is all I know.
Great! Thanks a lot!
Is there a way to create an image/pdf with CSS html and PHP? Output a PDF with multiple versions of [URL="http://imgur.com/buZKVVg"]these[/URL]. [editline]30th May 2013[/editline] Like rendering a div with a certain ID or class.
Hey guys, could use a little help on a little website a friend has contracted me to do. He's asked for the sidebar to follow the viewport, which it does fairly well using a jQuery addon called slider.js ( bootstrap didn't like the idea of using a fixed position all too well, although the addon seems to do the trick, for the most part ). Anyways, onto the problem: the sidebar works absolutely fine on safari, on chrome it works fine until you try to reload the page at a position anywhere other than the very top, and on firefox it stays in the correct place up until you try to actually scroll down. I imagine this has something to do with the slider colliding with another div element, but I can't for the life of me figure out which it is, and how to fix it for that matter. I've tried to give all the other divs toward the left a float: left; property, but that didn't seem to do shit. Site: [url]http://dgl.nickbella.me[/url] . The sidebar itself is called #social, and is the first div on the page ( aside from the container div ).
[QUOTE=Cassel;40838509]Trying to learn using mysqli and I came across this snippet; [php] $sql = <<<SQL SELECT * FROM `users` WHERE `live` = 1 SQL; [/php] Can someone explain what and why "<<<SQL ... SQL" is?[/QUOTE] I learned that mysqli is outdated and you should be using [url=http://henryranch.net/software/ease-into-sqlite-3-with-php-and-pdo/]PDO[/url], I find it a lot easier to work with as well. [QUOTE=eternalflamez;40837506]How about this: (Requires jQuery) [url]http://jsfiddle.net/emKkF/[/url] It orders them in the order of the id's given. I could also have it order on the classes themselves (min to max) but this way you wouldn't need to edit the js for each option, just the order of id's you give them in the php.[/QUOTE] Also thank you so much, between you doing nearly all the javascript for me and coment helping with my database functions I'm pretty much not even making my code alone anymore :V Aw dang, it doesn't work for large numbers. The data in the table is generated on the fly and I can't guarantee what'll come out, making the php order it is simply annoying, it'll have to regularly go into negative values (?) to order the table. Usually there are about 32 table rows, is there a way to order the table with ids that have 4+ numbers in them?
[QUOTE=Cassel;40838586]Great! Thanks a lot![/QUOTE] You're welcome [editline]30th May 2013[/editline] [QUOTE=01271;40840704]I learned that mysqli is outdated and you should be using [url=http://henryranch.net/software/ease-into-sqlite-3-with-php-and-pdo/]PDO[/url], I find it a lot easier to work with as well.[/QUOTE] Could you elaborate?
[QUOTE=01271;40840704]I learned that mysqli is outdated and you should be using [url=http://henryranch.net/software/ease-into-sqlite-3-with-php-and-pdo/]PDO[/url], I find it a lot easier to work with as well. Also thank you so much, between you doing nearly all the javascript for me and coment helping with my database functions I'm pretty much not even making my code alone anymore :V Aw dang, it doesn't work for large numbers. The data in the table is generated on the fly and I can't guarantee what'll come out, making the php order it is simply annoying, it'll have to regularly go into negative values (?) to order the table. Usually there are about 32 table rows, is there a way to order the table with ids that have 4+ numbers in them?[/QUOTE] Just do it with PHP, this isn't really something you need JS for, especially if there's only 32 rows. Getting the page to load faster is a bad reason for using JS because the amount of time it takes to do that sort in PHP is going to be imperceptible.
How can I style my site without using tables? Currently I use tables to put a menu on the left, an image in the middle, and some text on the right. Pretty sure that can be done without tables, but I don't know what to do. I tried using divs with align tags but that just places it on a new line. If you need to visit it I have a link on the left, under my avatar.
I think aligns only affect text (centering texts, or aligning to the right). You should use floats, I made a crude example: [url]http://jsfiddle.net/35NWv/[/url] For best practice you should give the divs ids and put the styles in a css file instead, when using it on your website.
[QUOTE=eternalflamez;40841787]I think aligns only affect text (centering texts, or aligning to the right). You should use floats, I made a crude example: [url]http://jsfiddle.net/35NWv/[/url] For best practice you should give the divs ids and put the styles in a css file instead, when using it on your website.[/QUOTE] Doesn't seem to work all to well. [img]http://i.imgur.com/YN9Vash.png[/img] I'll just keep playing with it I guess.
[QUOTE=kmlkmljkl;40841972]Doesn't seem to work all to well. [img]http://i.imgur.com/YN9Vash.png[/img] I'll just keep playing with it I guess.[/QUOTE] What about having 3 divs with the elements inside a div then give the parent div an X width, and the children an X/3 width? And/or display:table-row or display:table-cell. (I can't remember which one is which.)
How would I "hide" the file that my server gives to the client? For example: website.com/page when the file that displays the page is a php file. I am sorry if this was asked before, but I would not even know what to search to find this. [editline]30th May 2013[/editline] Ok I googled it and people are using htaccess files to achieve this, is this the best way of doing it?
[QUOTE=toaster_2.0;40843447]How would I "hide" the file that my server gives to the client? For example: website.com/page when the file that displays the page is a php file. I am sorry if this was asked before, but I would not even know what to search to find this.[/QUOTE] Apply two massages of [code] RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php [/code] in an .htaccess made in the root file for 14 days. Guaranteed results! By the way, my question about SQL stands... [quote] I'm trying to select everything from a row where sid = 114 (just for the example; it'll be a variable). Then, I want to count how many times is RowWhereSidIs114.ValueThatRepeats repeated in the whole table. [/quote]
[QUOTE=01271;40840704]I learned that mysqli is outdated and you should be using [url=http://henryranch.net/software/ease-into-sqlite-3-with-php-and-pdo/]PDO[/url], I find it a lot easier to work with as well. [/QUOTE] You're confusing mysqli with the old mysql functions. The mysqli is not depreciated and still a valid option and very similar to PDO in terms of use.
[QUOTE=Coment;40843501]Apply two massages of [code] RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php [/code] in an .htaccess made in the root file for 14 days. Guaranteed results! By the way, my question about SQL stands...[/QUOTE] 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.
Sorry, you need to Log In to post a reply to this thread.