• Questions That Don't Need Their Own Thread v3
    4,068 replies, posted
  • [QUOTE=Sprite;34396530]I can only assume that [B]<?=[/B] echos the content within. Thank you for this. my life made easier[/QUOTE] why the fuck didn't I know this 5 years ago?!
  • I still prefer not to use <?= because, as said before, you're not guaranteed that their server will support it if you're making a website for a client.
  • [QUOTE=Crhem van der B;34403895]I still prefer not to use <?= because, as said before, you're not guaranteed that their server will support it if you're making a website for a client.[/QUOTE] Is that really an issue? When I was doing client work, I had at the very least ftp access to the box (an .htaccess file is usually enough). Worst case scenario, you can just `sed` the directory and replace `<?=` with `<?php echo` and what-not, it's really simple stuff. Might I also add I haven't seen a server with short-tags disabled in quite some time, and that the echo short-tag (<?=) will be enabled by default in 5.4
  • [QUOTE=jaybuz;34406601]short tags killed my dog[/QUOTE] short tags make my code look nicer [editline]27th January 2012[/editline] This: [img]http://i.imgur.com/RrHKv.png[/img] looks better than having <?php .. ?> <?php echo ... ?> everywhere
  • [QUOTE=jaybuz;34406601]short tags killed my dog[/QUOTE] I would never do <? ?> but <?= ?> is so useful.
  • [QUOTE=zzlawlzz;34406764]I would never do <? ?> but <?= ?> is so useful.[/QUOTE] If it's your server I see no harm in using short tags. As this has been discussed before it always leads to the arguments of xml using the same open and close tag and that other php environments might not have it enabled. I feel this first snippet looks minutely better then the following example. [php] <? foreach($array as $k=>$v){ ?> Key: <?=$k?> => Val: <?=$v?> <? } ?> [/php] [php] <?php foreach($array as $k=>$v){ ?> Key: <?php echo $k;?> => Val: <?php echo $v;?> <? } ?> [/php]
  • [QUOTE=kingzl3y;34403780]why the fuck didn't I know this 5 years ago?![/QUOTE] Here's one for yah: [php] <p> <script language="php"> echo 'foo'; </script> </p> [/php]
  • Right, so I have a problem. I have a bunch of parts in a database, and I print the part number, name, model, amount and location into a table. [code] <tr> <td bgcolor="<? print $rowbg; ?>"><a href="itemdetail.php?cmd=edit&id=<?=$items[$i]["itemid"]?>"><font color="<? print $link; ?>"><?=$items[$i]["itemno"]?></font></a>&nbsp;<a target="_blank" href="http://fi.eetnordic.com/search.aspx?q=<?=$items[$i]["itemno"]?>"><img src="images/eet.png" height=10 width=25 /></a>&nbsp;<a target="_blank" href="http://www.google.fi/search?q=<?=$items[$i]["itemno"]?>"><img src="images/google.gif" height=10 width=10 /></a></td> <td><a target="_blank" href="http://www.google.fi/search?q=<?=$items[$i]["itemname"]?>"><font color="<? print $link; ?>"><?=$items[$i]["itemname"]?></font></td> <td bgcolor="<? print $rowbg; ?>"><a target="_blank" href="http://www.google.fi/search?q=<?=$items[$i]["konemalli"]?>"><font color="<? print $link; ?>"><?=$items[$i]["konemalli"]?></font></a></td> <td><iframe width="72" height="18" frameBorder="0" src="kpl.php?id=<?=$items[$i]["itemid"]?>"></iframe></td> <td bgcolor="<? print $rowbg; ?>"><font color="<? print $link; ?>">&nbsp;&nbsp;<?=$items[$i]["sijainti"]?>&nbsp;</font></td> <td align="right"><a href="javascript:doDelete(<?=$items[$i]["itemid"]?>)"><img src="/images/redx.gif" height=10 width=10</a></td> </tr> [/code] Problem is, the amount part. (kpl = amount) As you can see from the code above, I use an iframe. The iframe connects to the database, fetches the amount from the database. I have 2 images, a plus and a minus sign, when you click on either one, it takes you to another page, does the shit there, and redirects the page back to the one with the amount and plus and minus signs. Now, this was a quick solution I made at the time, but I need something better, because of reasons you can probably guess (500 parts, 500 iframes fetching shit from database on page load, how about fuck no). The main reason I do that, is because I need to update the amount that is shown, and it's easy with an iframe, you just reload the damn thing, but does anyone have another solution that doesn't suck balls? TL;DR: I have a value on a page, I have it in an iframe right now because I need to update the value without reloading the whole page, is there a way to update the value without reloading the whole page, without using an iframe? [editline]27th January 2012[/editline] Apparently AJAX would be needed for this. Fuck. I've never really used JavaScript or XML. [editline]27th January 2012[/editline] Apparently jQuery has nice functions which can do what I want. I think I'll do that. If I understood it correctly, I need to have the shit inside a div, and then I can somehow reload that div or something. [editline]27th January 2012[/editline] Some part of my brain is telling me that won't work and I should just bloody do it as pages and have like 20-40 parts a page. [editline]27th January 2012[/editline] On first load, load value from database with PHP, inside div. User clicks either value-changing button, load PHP-page in background that does the change, after that happens, another, new page, gets loaded into div, that is basically the iframe thing I'm using now, because I only need the speed upgrade for the situation that main page is loaded.
  • I'm kinda looking for a way to do smooth javascript page updates Right now because our group is a forever work in progress we have devnights pretty much include all of our server owners and people to do any kind of work pertaining to the group's organization. We used to have them in our steam group chat but that sorta sucked and always went off topic. Last time I made a page with two iframes On the left I had an iframe page that would auto refresh every 15 seconds with a list of things we are talking about I would edit the HTML and upload the page as we progressed and actually went a bit more smoothly than one might think and on the right we have a mibbit IRC chat For the left page though it would do really shitty reloads where the page would flash white for a moment load reload and it got really annoying. Would there be a better way to do this or perhaps a way to push updates only when they happen? I have seen a Minecraft plugin (best example?) called Dynmap, Essentially it live updates a giant Google maps map of a Minecraft server as the server is worked on, you can see players moving around on the map in real time as well as them chatting. [url]http://minecraft.almost-there.org:8123[/url] It updates very smoothly and I would like to know exactly how that works.
  • Why don't you use Google Docs, you can chat and live edit all at the same time.
  • Let's say I've got an array of id's - 1, 2, 4, 6, 10 etc - array could vary in size (from 2-3000) and let's say that I have a condition that says if id 2 is in that array echo this, and/or if id 10 in that array echo this. I know IF/Switch would work, but I wonder if there's a more efficient way of doing it?
  • [QUOTE=kingzl3y;34420580]Let's say I've got an array of id's - 1, 2, 4, 6, 10 etc - array could vary in size (from 2-3000) and let's say that I have a condition that says if id 2 is in that array echo this, and/or if id 10 in that array echo this. I know IF/Switch would work, but I wonder if there's a more efficient way of doing it?[/QUOTE] uh [php]<?php $arr = array('soemthing'); $rand_number = mt(1,1000); $rand_number -=1; foreach($arr as $number => $echo) { if($rand_number == $number) { echo $echo; } } ?>[/php]
  • If you are looking for real time collaborative party programming check out [url]http://www.saros-project.org[/url] otherwise just use google docs like jaybuz suggested.
  • [QUOTE=jaybuz;34419145]Why don't you use Google Docs, you can chat and live edit all at the same time.[/QUOTE] [QUOTE=hacksore;34421218]If you are looking for real time collaborative party programming check out [url]http://www.saros-project.org[/url] otherwise just use google docs like jaybuz suggested.[/QUOTE] I did know about google docs, but it really isn't what I want. :/ The idea is that it would be an application built and running on the website Also we have some anon members who don't want to use their google accounts.
  • [QUOTE=lkymky;34425927]Played with websockets a bit, I can't figure this shit out though.[/QUOTE] what language
  • [QUOTE=Ac!dL3ak;34426245]what language[/QUOTE] javascript (oh god the boxes....)
  • How are tags for youtube videos stored? In a single row within a table? or ... do they have a pointer to a group of tags [I]is it this[/I] [B]YouTube Videos Table[/B] title: Carbon Horse tags: henry fords car beats horses streamData: 101010 etc: [I]or this[/I] [B]YouTube Videos Table[/B] title: Carbon Horse tagGroupPointer: 9464 streamData: 101010 etc: [B]Tag Table[/B] groupID: 9464 tagWord: henry -------------- groupID: 9464 tagWord: fords -------------- groupID: 9464 tagWord: carbon -------------- groupID: 9464 tagWord: horse -------------- [editline]28th January 2012[/editline] I ask "what does youtube do?" because they are most likely doing it the best way. So what is the best way? It looks like the tagtable... hrm. yeah. looks legit [editline]28th January 2012[/editline] What kind of int does Twitter use when they store tweets in a table? Each tweet has an ID.... but ... ... not even BIG INT covers "163221013486772224"
  • yeah. I should have actually done the math before I trusted my hyporbole
  • So in javascript I have a form [code] var iWzrost = document.forms['BMI'].Wzrost.value;[/code] I get a value from it , the user is suposed to input in a number like "1.5434", but this is a european website so users will input it like so "1,54535" ,how do I fix or convert that to a number?
  • [QUOTE=swift and shift;34430071]parseFloat(document.forms['BMI'].Wzrost.value.replace(",",".")) also don't use hungarian notation[/QUOTE] Can I ask why is it not advisable to use it?
  • [QUOTE=marcin1337;34430082]Can I ask why is it not advisable to use it?[/QUOTE] [url]http://www.joelonsoftware.com/articles/Wrong.html[/url]
  • [QUOTE=lkymky;34427193]javascript (oh god the boxes....)[/QUOTE] no shit sherlock i meant the server
  • I've come to the conclusion that I'm pretty much color retarded. Either that or I just never like the colors I choose. I use stuff like Adobe Kuler but was wondering what you guys use?