-
Posts
579 -
Joined
-
Last visited
Posts posted by Drongo_III
-
-
Ahhh....i was trying to use braces but i wasn't wrapping the whole variable. haha that makes me wonder about something else...
Do curly braces tell php to interpret that part first?
Err... mind explaining to me why you wrapped it in double quotes and then concatenated?
That is actually a very good question, I am tempted to say it has something to do with greedy token, but that wouldn't make any sense. If anyone knows please share!
But alternatively you can use braces like so (it's more readable in my opinion):
"INSERT INTO 2012hitting (hr) VALUES ('{$myArray[0][3]}')"
Or you can just asign the array value before hand and insert a regular string like so:
$myValue = $myArray[0][2]; $sql = "INSERT INTO 2012hitting (hr) VALUES ('$myValue')";
-
Well that sounds like a pretty decent explanation to me
I was more concerned there was some fundamental syntax thing i had completely overlooked.
It's good to know how to make it work though so thank you very much!
To be honest I don't know the actual reason. You can place a single postion into a "" string:
$a[] = 'ss'; echo <<<_END $a[0] _END;
But when you chuck in another dimension with the extra set of square brackets, php trips up.
So as your query in $sql is essentailly a string, by breaking the string and joining it to the array pos, then joining the rest of the query to the end the $sql... $sql then becomes the string you wanted it to be in the first place.
However i'm pretty sure there is a better explanation.. and I would actually like to know it too... i notice you have Adam reading this thread.. hopefully he will be able to give a better explanation to the one i gave
(you can actually write less code there by placing the query directly into the mysqli:
$mysqli->query( "INSERT INTO teams (company) VALUES ('".$myarray[1][1]."')" );
-
That worked a treat! Thank you.
Err... mind explaining to me why you wrapped it in double quotes and then concatenated?
Is this some way of make it interpret the next level down in the array?
This should work..
$sql = "INSERT INTO teams (company) VALUES ('".$myarray[1][1]."')"; $mysqli->query($sql);
-
Hi Guys
Clearly I still have lots to learn...
I am trying to insert (using mysqli) multi-dimensional array values into the database, but when i do the value that gets stored ends up as "$Array[1][1]".
Here's the test query i am running:
$sql = "INSERT INTO teams (company) VALUES ('$myarray[1][1]')"; $mysqli->query($sql);
So do i need to break the data out of the multidimensional array for the insert? Or is there some syntax thing i've missed?
Or worse still do i actually need to do:
$value1 = $myarray[0][0];
Any help would be very much appreciated!
Drongo
-
Hi Zane
Thanks for the reply.
Is that one you've used?
-
Anyone help? :'(
-
Ahh well i can't be of much help in that case sorry :/
I would have thought using ajax to prompt the ad server into refreshing your ads sounds reasonable - but that's assuming a server setup exists to allow you to do this.
I use ad companies, so similar to Google's adsense, I just insert the code (javascript) and they handle the rotation as pages are refreshed... or in this case, when the code is called again.
Doing it in iframes is easy, just set the iframe html page to refresh at the rate that I want.
It's that I don't know if Ajax would be better or run smoother.
-
Well entirely your choice and you know your site better than i do. I would seriously consider not using ajax for this though if you have a standard website.
As i dont fully understand your setup I can't see how you'd make this work with iframes. Unless you intend to iframe in content from companies who will themselves handle all the coding their end?
How exactly do companies provide their ad code to you?
Presumably companies provide you with some ad creative and a url?
1. Users are on my pages for hours at a time.
2. Preloading ads doesn't seem like it would work, as I don't know how long a user is going to be on my site. Using more server resources isn't a big issue, but taking advantage of long time that users stay on a single page is. I'm simply trying to make enough money to make the current ad placements worth while, and it seems like the one thing to take advantage of for my site and the length of time users spend on pages, is to show them new ads every 5, 10 or 20 minutes.
I'm fairly certain I want to use ajax or an iframe, but it seems like ajax is the slicker way to do it. Since I'm not a programmer tho, I'm concerned if this would have problems as the ajax would be rotating different ad companies ad code. Thoughts?
-
err not ajax...i meant jquery
Can you post the php script that the ajax is targeting?
At the moment everything you've posted is html and ajax...not php.
-
I'm not entirely sure what you're after here. But would it not make more sense pre-load in a random selection of ads on page load? I suggestion this for two reasons:
1) What is the average time a user spends on one of your pages? I bet it's not much over 2 mins so refreshing ads via ajax is a bit pointless.
2) Imagine an average person on your site. They visit, they might sit on a page and leave their browser open whilst doing something else (anywhere from a few minutes to a few hours). If that was happening for hundreds/thousands of users you'd end up making server requests via ajax every two minutes for each person - presenting users with ads when they aren't even there to see them. So you're tying up your server resources for absolutely no benefit.
Personally i would preload in a range of ad urls to a javascript array and then use some other javascript/jquery to cycle them on a periodic basis.
Drongo
-
Can you post the php script that the ajax is targeting?
At the moment everything you've posted is html and ajax...not php.
-
Nop - jquery will reset the style and unhide it when the function is called.
Jquery is like magic
but won't that hide it even when the script tells it to show?
-
Just set the thank you div style to display:none;
how do I hide the thank you div by default?
-
Or a maybe a better way might be to use a callback functino call from your AJAX to call a function that does the above.
-
Hi Mate
Probably easiest if done with jquery. Something like:
<script> $(document).ready(function () { $("#FormSubmitButtonID").click(function(){ // Logic to determine the form is ok to submit. $('#YourFormID').hide(); $("#YourThankYouMessageDivID").show(2000); }); }); </script>
Tapping that in off the top of my head, and i always typo javascript, but it is a simplistic example of what you want.
-
Not sure you could use isset() because you're not refreshing the page and so not parsing anything.
You're best option is probably to fire a javascript function (onsubmit) that will hide the form and display your message.
-
Hi Guys
I have a client who wants me to setup a web application to enable video conferencing for people logged into a special client area.
Can anyone recommend the best direction to go with this? I've never setup anything to do with streaming live media before so I'm at a bit of a loss.
Few google searches have turned up silverlight but can anyone suggest better options? i.e. flash? Or a java applet of some kind?
Any advice in the right direction would be good!
Drongo
-
Hey mate
This is a bit rough and ready but it will give you the general idea. You need regular expressions for this and i've explained how you test them below:
<?php $subject = "abcdc ef"; $pattern = '/^[a-zA-Z\s]+$/'; // This tests the above pattern against the string provided - that would be the string from your form $test = preg_match($pattern, $subject); if($test == true){ echo "all ok"; } else { echo "bad string - please retry"; } // pre_replace will search your string for excess white space and remove it - but it will preserve single spaces $str = preg_replace('/\s\s+/', ' ', $subject); echo $str;
-
Hmm i think the best solution to that will come out of you becoming much better acquainted with google maps api (which i'm not).
But i would imagine your stock table (simplifying this of course) might have a related table for store locations (so every product is assigned to one or more stores). You might store the geolocations of those stores in the DB since they wont change.
Then when someone browses for say 'pumpkins' on your site, your script looks up the item, and finds the stores in which that item is located. So you now know that pumpkins are stocked in store 1 and store 2 and you have the geolocations of those stores.
You might then have a "user location " function and a "distance " function.
The user location function would pinpoint the user's location. The distance function would 'range check' the user's location relative to the store locations you've stored. Then you might run another function to display this data on the map (through google maps api).
As i said that's all very simplified and speculative as i'm not overly familiar with google maps api but i reckon that's doable.
Hi,
Many thanks for the prompt response. I can read through the links that you sent me and see what I can come up with.
I just have one more question - How do I link the maps to my stocklist?
Thanks.
-
Ermm you tried just setting the link as "/blah.asp/"
Everytime I make an announcement/post with a link like so: "This is an announcement with the following link: <a href="http://www.blah.asp">link</a>"
It never goes to the actual webpage. It always goes to a "not found" page on my website like so: http://mywebsite.com/"http://www.blah.asp/"
-
Very often when building your own cms people use things like this - http://www.tinymce.com/ to provide a wysyywig environment that updates the html code.
You just need to code that into your site. But all of this is a big ask if you are very new to php so check out some open source cms packages.
A very easy one i have used is concrete5 . Soooo easy to create a new theme and templates.
I need this particular Ques's answare.
Coz i know html, css & javascript.
I wanna write a site like that i said before.
So can u tell me which part of php or mySQL need for do that..?
-
Not overly familiar with Google maps API as haven't really used it much.
But in theory it's perefectly possible to get their location (i.e. gelocation - http://code.google.com/apis/gears/api_geolocation.html )then have a script on your site that would calculate the closest shop (if product exists) using something like google maps distance matrix thingy - http://code.google.com/apis/maps/documentation/distancematrix/ . And if you've gone that far then displaying the shop location on a google map should be a piece of apple pie!
-
err no, || is like OR
so basicly || is like an AND.
thanks for the help!
-
text doesn't necessarily mean it's going to be considered text by php.
You can specify the type as 'number' but this is a HTML 5 thing and won't have wide support.
Your best options are to either use jquery/javascript to validate at the client side (though this would fail if they didn't have JS turned on) or post your data to a validation function and use something like:
$yourinput = $_POST['yourinput']; filter_var($yourinput, FILTER_VALIDATE_FLOAT)
...with a conditional to check the input validates to a float - i believe it returns true if it's valid.
If not then return the user to the form with the appropriate error.
Inserting multidimensional array value into mysql
in PHP Coding Help
Posted
well i feel like i've learned something today![:)](https://forums.phpfreaks.com/uploads/emoticons/default_happy-01.gif)
I think i'm down with the curly braces club freelancer...seems easier to read to me. So you're out there on concatenation island on your own i'm afraid hehe.
Thanks for all that chaps. Has helped a lot!