-
Posts
5,717 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Adam
-
[SOLVED] Multidimensional Array make Single Array?
Adam replied to rasherb's topic in PHP Coding Help
Try this.. <?php // array defined here $key = array_search('Pink', $cds); if ($key !== false) { foreach ($cds[$key] as $cd) { $matchedCDs[] = $cd; } } print_r($matchedCDs); ?> A -
Playing with it a little more there are a few features of reg ex 'not yet implemented' .. if they can work those out though, be' top notch! A
-
Check that link. There's something on one of them that opens Google, perhaps you could change that slightly? A
-
Google it .. Just a popular script. It's made for images but I believe you can mod it for your own needs.. sounds similar to what you're saying! Look at this page, might find what you're looking for: http://miniajax.com/ A
-
Hmm that's odd? Never had a problem like that... What browser are you using?
-
Try something like: $key = array_search('something', $_POST); A
-
Fair enough, but then again you can have such complex syntax as: ${$a[1]} and: ${$a}[1] with just plain old variables.. Isn't ${1}1 just so that the trailing 1 will be treated as a literal? A
-
Hah boy do I feel foolish! Though I would still consider them variables being as they represent...variable data?
-
Sounds a bit like "light box" .. A
-
genericnumber1: In preg_replace() $1, $2, etc. are valid variables that can be used within the replacement parameter.. http://uk3.php.net/manual/en/function.preg-replace.php Also: $test = 'value'; echo 'test: $test'; ...will still produce "test: value" .. jaymc: Quite fine to use $1, $2, etc but I'm not sure you can use them to call another function from within preg_replace?? You need to remove the single quotes from the arrays though, unless you have created them that way? $data['1'] = 'foo'; // valid way to do it but.. print $data[1]; // ... won't work! print $data['1']; // .... will! $data[2] = 'bar!'; // valid way to do it but.. print $data['2']; // ... won't work! print $data[2]; // ... will! Remember 1 != '1' .. I'm not saying this will definitely work though.. A
-
Sorry I misread your question slightly before... Can you post your actual code? Also how many rows are pulled from that database (roughly)? Just that $var is going to be overwritten every time your 'while' makes a loop and it could just be that the last record returned is simply empty! A
-
Can you explain it a little more clearly? Do you mean to kinda 'unset' $var after the loop for re-use? .. or do you mean to carry the data out of the loop, for use later on? A
-
http://www.phpfreaks.com/forums/index.php/topic,95433.0.html A
-
Far better than before! Does have the simplistic look too it. Pretty much the only thing I don't like, and this is a little picky, is the outer glow on the Canadian flag symbol.. Nothing else has one so it stands out a little from the rest of the page. Get it coded! A
-
Either in the JS as you call the 'ajaxpage' function, or in the PHP as you load each page, you'll need to update the cookie to the new page... A
-
Hah sorry.. Do you mean something more like: foreach ($_POST as $val) { if (substr($val, 0, 5) == 'format') { $str .= (strlen($val) == 6) ? substr($val, 5, 1) : substr($val, 5, 2); } }
-
var currentUrl = document.location.href; Does this help? A
-
<?php $i = 1; while ($data = mysql_fetch_array($result)) { $id = $data[0]; $section = $data[1]; $value = $data[2]; $image = $data[3]; ?> <img src="../<?php echo $image; ?>" /><br /> <?php echo $value; ?><br /> <input type="checkbox" name="format<?php echo $i; ?>" value="<?php echo $value; ?>" id="format<?php echo $i; ?>"/> <?php $i++; } ?> A
-
Waah? Database? Sorry I had no idea this was what you were trying to achieve. I simply rewrote the code you had in the onfocus and onblur attributes... As cytech says..
-
Jeez, not with it today. Get what you mean now: var page = document.cookie.match(/page=[\w][\w\-\.]+;/); if(page != null) { ajaxpage(page, "content); } else { ajaxpage("default", "content"); } A
-
Sorry my bad, I didn't realize 'default' was a reserved name! <script type="text/javascript"> <!-- function defaultValSwitch(obj, def, e) { var val; if (e == 'onfocus') { val = (obj.value == def) ? '' : obj.value; } else { val = (obj.value == '') ? def : obj.value; } obj.value = val; return; } //--> </script> A
-
Try this: <script type="text/javascript"> <!-- function defaultValSwitch(obj, default, e) { var val; if (e == 'onfocus') { val = (obj.value == default) ? '' : obj.value; } else { val = (obj.value == '') ? default : obj.value; } obj.value = val; return; } //--> </script> <input name="customerRef" type="text" class="fields" id="customerRefField" onfocus="defaultValSwitch(this, 'i.e ITA001', 'onfocus');" onblur="defaultValSwitch(this, 'i.e ITA001', 'onblur');" value="i.e ITA001" size="25" /> Note that I've switched onclick to onfocus! A
-
Post the code as you have it... A
-
I've posted a solution in the other topic that got moved! A