-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
But as you pointed out, he should be using an array anyways
-
You wouldn't have to use eval() for it. Just access it through the window object. window["itm" + i].model Ah, the flexibility of JavaScript. Oh yeah...duh...i even wrote a script the other day doing that...can't believe that slipped my mind...you win again old age
-
hmm also I don't think requinix's example quite matches what you are trying to do. I think what you are looking for is the following: <script type='text/javascript'> var itm = [ {"make" : "porche", "model" : "boxter"}, {"make" : "mazda", "model" : "protege"} ]; var g = <?php echo $count?>; for(i=1; i<=g; i++){ $('#writer').append(itm[i].model + "<br/>"); } </script>
-
I agree with requinix but to more directly answer your question, the problem is that this: var handle = "itm" + i +'.model' ; just makes a string with a literal value of "item2.model". In order to get it assign a value like that, you would have to wrap it in an eval() call, which will cause whatever string you pass to eval() to be executed as javascript. But you don't really wanna do that. At best, it is bad practice. At worst, it opens up all kinds of potential security holes.
-
This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=359477.0
-
This topic has been moved to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=359468.0
-
Regex pattern to not match if string contains something.
.josh replied to huddy's topic in Regex Help
Well if we're going with the assumption that s01 immediately precedes ep01 or e01, and that 01 is literal (as opposed to being any 2 digits, requinix's pattern would be more efficient just using literal 01 rather than char classes: /(?<!s01)ep?01/i -
This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=359402.0
-
Here's an idea: don't do it. If you are looking for a fun way to learn web development, and it's purely for personal/academic reasons, then okay...but if you think you're going to get rich off it...lol.
-
creates scope, puts inside namespace, makes it to where you can't call clickListener() from just anywhere
-
I'd personally import into a single table first and then create your other tables from that, yes. Mostly because it will be less work involved on the php end to pop data. No having to to keep running through csv file and looping multiple times, etc..
-
at the bottom of your script you have a header() call.. comment it out and run your script... do you see any errors displayed?
-
1) Are your php variable values outputting in your js onclick? (view source of rendered page to verify) 2) Are the js variables being passed to your buildingClick() function? (use alert() or console.log() to verify) 3) mywin = window.location.href = "informationPage.html"; might possibly be problematic...you are setting the current window's location to a new location too.. stands to reason you are being redirected to informationPage.html before the rest of your js has a chance to execute 4) mywin.document.getElementById("infoArea") I see in your informationpage.html the div id is "infoDiv" not "infoArea"
-
"parameter 1" is the (optional) 2nd argument to mysql_query, where you specify your database connection resource. If you do not specify the connection resource, php internally attempts to look for an established resource within the scope of the mysql_query() call. The problem is that it is looking for the connection resource and can't find it and it is returning false, so the mysql_query() function is trying to use "false" (boolean value) as the connection resource. So either a) you have not established a connection to your database (you should be doing this with mysql_connect() to make the connection, and mysql_select_db() to select which database) or b) If you do have connection code somewhere before the code you posted, then your code is not within the scope of your established connection. This commonly happens when you create a connection in the global scope, but then try to perform a query within a function.
-
trying to retrieve the last id of a record inserted
.josh replied to davids_media's topic in PHP Coding Help
that's not a very helpful response.. remember, we don't have the benefit of sitting in front of your computer to see what is actually happening, so you need to be more detailed...well when you tried it, what happened? is the prodID echoing out or not? -
for ($c = 0;$c<24;$c++) { echo date('g:00 A',strtotime("+$c hour",mktime(0))) . "<br/>"; }
-
trying to retrieve the last id of a record inserted
.josh replied to davids_media's topic in PHP Coding Help
Your "if" condition will always be true, because it is evaluating the assignment of something to a variable, not the value of the variable. Try echoing out $_GET['prodID'] to see if it is really set. -
HELP PHP FORM SHOWING SERVER INFORMATION IN EMAIL?!?
.josh replied to webshark360's topic in PHP Coding Help
my first guess is that your email script isn't setting email headers properly (eg: the "From: ..." header). But what darkfreaks said. -
except that prices vary a little more than realistic/feasible "estimate" ranges depending on what part of the country (or world even) you are in... for instance, I pay about $2/pound for ribeye steak at my local grocery store...but I do live in farm country, where I can go pet my meal before I eat it if I really want to...but traveling around the states, I've seen it upwards of $10/pound even upwards of $20/pound in some places... or like a loaf of bread...I pay ~$1 (more like 75c but I round up), $1.50-$2/gal for milk.. but I've been to places that charge like $3 per load of bread, $5 for gallon of milk... even an overall "average" price throughout all of the US (or world) would be too much of a difference in my case for a lot of things...
-
I get what jesirose is saying. It's easier to estimate things like your monthly phone or water or cable bill. You know about how much you consume and with the exception of seasonal price hikes by greedy bastard asshat companies, you can more or less put a solid number down in like 2 seconds. Even easier for bills like rent or car payment, where unless some major change happens (like refinancing, etc..) that number is going to stay the same every month. But unless you are basically old and set your ways (ham and peas every tuesday night sort of thing), your weekly/biweekly/monthly/whatever grocery bill is a lot more volatile, a lot harder to pin down an average total to figure into things when trying to budget for things. Especially when you consider that for most people "groceries" is not strictly food; it's basically all the other non-major things you own as well. Other consumable things like toilet paper and soap. Dishes and spoons and forks (even these tend to be consumables when you have a houseful of kids!). Clothes you buy, random "office" supplies, esp if you work from home, etc... So with "groceries" it's not so much about nickel and diming things, but getting a decent estimate on what you're going to spend for the week/month on groceries, so you can work that into figuring out all your bills and shit. I don't really care if peanut butter costs $2.42 one week and $2.60 the next week. What I do care about is knowing that overall on average I'm going to be spending about $2.50-$3 on a jar of peanut butter, so that when I make a grocery list and I know I have x amount of money to work with, I can better figure out what all I can get. It's not an exact science and I'm not really looking for it to be. Okay, well if I'm broke and I know I have to make $20 feed me for the next week, sure, I do tend to account for literally every penny... but in general when I'm just tryin' to manage all my bills and finances, trying to figure out bills...I'm not really interested in looking at the money at that granular of a level. I spend ~$1200 a month on groceries (I feed a lot of people!) I'm just not interested in whether or not that jar of peanut butter was $2.42 or $2.60. I buy too much shit to look at it so granular. Sounds like jesirose maybe wants to be a little more granular than me, but overall same principle... anyways, IMO something like this would be better as a mobile app. There are already apps out there that let you scan barcodes and it will query some database somewhere and tell you what the product is. I'm thinking a mobile app that taps into that, and then allows you to enter in the price for it. Then you can easily query the numbers and get averages.
-
In a given forum thread listing you can click the column header and sort by that column.
-
also you should be sanitizing those values before inserting them into your db...
-
@kicken: lol I remember playing #2 w/ paper/pen when I was a kid, sittin' in church w/ my siblings
-
I'm a big fan of "generator" type scripts, especially ones that have to do with words. Example: IT Department [name] Generator from seventh sanctum
-
oooh actually I found a bug in my pattern...apparently it will match partial numbers. For example: 112 5 6 12 5 7 8 7 5 7 8 7 3 21 12 5 60 Pattern will match "12 5 6" that's no bueno... Here is an updated pattern that makes use of lookarounds to make sure it matches whole numbers... $string = "2 0 7 1 1 7 1 1 6 8 7"; preg_match('~(((?<!\d)\d+\s?){3,}).*(?<!\d)\1(?!\d)~',$string,$matches); $number = $matches[1];