Jump to content

tomfmason

Staff Alumni
  • Posts

    1,693
  • Joined

  • Last visited

Everything posted by tomfmason

  1. you are wanting the range function <?php $var = 5; foreach(range(1,$var) as $num) { echo "$num<br />"; } ?>
  2. open mouth and insert foot I answered that because while everyone else was giving you the correct answer no one had actually answered the question you asked. There are very very few occiasions where this would be a correct method. An example(correct) usage would be from my cakephp rest implementation. Another example could be something like this <?php class Foo { function dispatch($method) { $m = "do_$method"; if(in_array($m,get_class_methods($this))) { return $this->{$m}(); } else { return "invalid method"; } } function do_something() { return "Something"; } } $foo = new Foo(); echo $foo->dispatch($_GET['method']); ?> As others have stated there are very few occasions where this would be a correct method. Your case would be much better suited with an associative array.
  3. I haven't done any work with the twitter api in php but I have worked rather extensively with the api in python and have ran across the same problem. The solution for me was to simply choose a different format - in my case json. See - http://dev.twitter.com/doc/get/statuses/user_timeline It should return the latest 20 tweets.
  4. as others have stated an array would be a much better option but here is an answer to the OP <?php $foo = "bar"; ${$foo} = "test"; echo $bar; ?>
  5. It sounds like you are looking for a php based cron manager. A quick google search came up with this - http://ryanfaerman.com/php-crontab-manager/ . It is not a completed solution but it does seem like it would be simple enough to use in developing something that will suit your specific needs. Also, I am in the process of working on a python(using twisted and django) based project that does almost exactly what you are describing. It is still in the early pre-alpha stages but it will end up being opensource.
  6. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=314466.0
  7. this is how you setup a cron with hostgator - http://support.hostgator.com/articles/cpanel/how-do-i-create-and-delete-a-cron-job and here is a php snippet that empties a directory- http://snippets.dzone.com/posts/show/5004
  8. There are several command line recorders. For example, arecord, sound-recorder ect. The only problem I see is stopping the recording. I am not sure if simply killing the process would mess up the recording or not. You could test it with sound-recorder and see if it does or not. Start a recording: sound-recorder -P song.wav and then simply kill the process.
  9. I know nothing about your setup. It should be as easy as finding the correct url and editing the link
  10. When you click on "add to cart" it appears that it sends an ajax GET request to http://nailaccents.com/wp-content/themes/shopperpress/functions/ajax/actions.php which returns a 404 not found.
  11. So, basically high prices on beer avoids drunkenness. The same measures they take on smokes. In Belgium you are basically "forbidden" to smoke. Only allowed in places where they don't serve food. But every pub (cafe?) has to serve food to make a good income. oddly enough it is basically the same in the states. The only place that i know of locally that serves food and allows smoking are the native american casinos. I am not sure if that is because they are their own sovereign government or not.
  12. basically the code I posted should serve the intended purpose but there is most likely a better way to do it.
  13. There may be a better way to do this but here is a quick and dirty(working) solution var b = []; var buttons = ["btn1","btn2","btn3"] var btn = [] function counter(id,n) { btn[n] = document.getElementById(id); btn[n].disabled = true; if (b[n] < 2) { btn[n].disabled = true; btn[n].value = 'Wait... ' + (2-b[n]); b[n]++; setTimeout("counter('"+id+"',"+n+")", 1000); } else { btn[n].disabled = false; btn[n].value = 'test'+(n+1); } } window.onload = function() { for(var i=0;i<buttons.length;i++){ b[i] = 0; counter(buttons[i],i); } }
  14. it is getElementById not getElementByID
  15. I don't see where the variable currInsTable is defined. If it is not a variable then you need to enclose it in quotes like this: var tableToRemove = document.getElementById('currInsTable'); currInsurance.removeChildrenFromNode(tableToRemove); var tbl = document.getElementById('currInsTable');
  16. That makes me want to immigrate
  17. If we seem a bit rude at times it may be because most of us deal with kids with an inflated sense of entitlement on a regular basis and it gets old after a while. We are always open to constructive criticism but we don't take flaming very well.
  18. I think it is not really how long it takes to learn php but rather how long it takes for it to "click" that matters. After it "clicked" for me I was able to pick up new languages in a matter of days/weeks instead of months like it took with php. I still do that to this day. I have well over 200 domains and I would bet that 80% or more are from scrapped ideas
  19. I got bored and decided to mess around with this a bit. First I downloaded the same db that you have from sourceforge. Then I had to modify the function that I linked to in my earlier post. The mysql function(modified for the db from sf) DELIMITER $$ DROP FUNCTION IF EXISTS `GetDistance`$$ CREATE FUNCTION `GetDistance`(lat VARCHAR(120), lon VARCHAR(120), lati VARCHAR(120), longg VARCHAR(120)) RETURNS VARCHAR(120) BEGIN DECLARE lon1, lon2, lat1, lat2, distance DECIMAL(12,; select CAST(lon as DECIMAL(12,) into lon1; select CAST(lat as DECIMAL(12,) into lat1; select CAST(longg as DECIMAL(12,) into lon2; select CAST(lati as DECIMAL(12,) into lat2; select ((ACOS(SIN(lat1 * PI() / 180) * SIN(lat2 * PI() / 180) + COS(lat1 * PI() / 180) * COS(lat2 * PI() / 180) * COS((lon1 - lon2) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) into distance; RETURN distance; END$$ DELIMITER ; and here is the simple proof of concept(in no way production worthy) <?php $link = mysql_connect('host', 'user', 'pass'); mysql_select_db('db'); $zip = $_GET['zip']; $distance = $_GET['distance']; $s = "select latitude,longitude from zip_codes where zip='$zip'"; $r = mysql_query($s); $cords = mysql_fetch_assoc($r); $sql = "select * from `zip_codes` where GetDistance('{$cords['latitude']}','{$cords['longitude']}',latitude,longitude) <= $distance;"; $res = mysql_query($sql); while($row = mysql_fetch_assoc($res)){ echo $row['zip'] . " "; echo $row['state'] . " "; echo $row['latitude'] . " "; echo $row['longitude'] . " "; echo $row['city'] . " "; echo $row['full_state'] . "<br />"; } mysql_close($link); ?> The code above is in no way production worthy. It was only meant as a proof of concept and should not be used where anyone other than the developer has access to. I used the zip from your example (17241) and the distance of 10 ie zip=17241&distance=10 output
  20. I think you can use this in a .htaccess SetEnv no-gzip dont-vary
  21. I would use distance from the given zip instead of the actual zip. This would make it easier for your users to find postings close to them. The chances of someone finding one within their zip would be pretty low unless they live in an urban area. Here is an example of finding the distance between two sets of long/lats in mysql - http://www.imranulhoque.com/mysql/mysql-function-to-find-distance-between-two-places-using-latlong/
  22. you can make all of the text in the textarea bold but afaik there is no way to make selected words bold
  23. how about this: function ChangeStyle(style){ document.getElementById('stylesheet0').href = '_css/styles_a4'+style+'.css'; } usage <a href="#" onlick="changeStyle('laertes')">Change style to Laertes</a> <a href="#" onlick="changeStyle('ophelia')">Change style to Ophelia</a> <a href="#" onlick="changeStyle('polonious')">Change style to polonious</a> <a href="#" onlick="changeStyle('base')">Change style to default</a>
×
×
  • 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.