Jump to content

damiantaylor

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

damiantaylor's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi guys, I've seen a lot of posts with this question but I still haven't managed to get it working! I have the following URL: www.myurl.com?&fltAccessories=Steel File & Oxide Stone I'm using the following code to read all the $_GET variables while(list($key, $value) = each ($_GET)) { .... .... } Problem is, $value contains 'Steel File' in this example. I've tried urldecode around the $_GET but to no avail. Anyone any idea how to make this work?
  2. Hi guys, I'm really struggling trying toremove duplicates from an associative array. I've tried array_unique but it doesn't work. Can you point me in the right direction please? I'm populating my array using the following code foreach($category['manufacturers'] as $manufacturer) { list($name, $id) = explode("|", $manufacturer); $brands[] = array("id" => $id, "name" => $name); } If the array contains: id = 1, name = brandA id = 2, name = brandB id = 1, name = brandA I'd like to remove either the first or third entry. I always struggle with associative arrays :'(
  3. Hi, I have a form (get method) with a couple of check boxes on it, each check box has the same name: <input type="checkbox" name="price[]" value="10"> <input type="checkbox" name="price[]" value="20"> When I hit the submit button, the URL passes the square brackets as %5B%5D. The php script that processes the form still recognises it as an array so it works ok, but it looks untidy. Is there a way to make the square brackets show as [] in the URL rather than %5B%5D? Or, is there an even better way to pass the checkbox values? Thank you!
  4. Hi guys, I'm trying to create a form that passes parameters in the URL when submitted. Here's the HTML code for my form: <form name="product_filter_form" action="http://page.php?main_page=index&cPath=8" method="get"> <input type="hidden" name="main_page" value="index&cPath=8&" /> <input type="checkbox" name="Price Range[]" value="£10 -- £20" />£10 -- £20<br /> <input type="checkbox" name="Price Range[]" value="£20 -- £30" />£20 -- £30<br /> <input type="checkbox" name="Price Range[]" value="£30 -- £40" />£30 -- £40<br /> <input type="submit" value="Go" style="width: 65px" /> </form> When I submit the page the URL contains 'page.php?main_page=index%26cPath%3D8%26' instead of 'page.php?main_page=index&cPath=8&'. Is there a way to make this work passing the parameters without hex code? Thank you
  5. Perfect! Thanks everyone for your help
  6. Thanks for your help guys! I've now got page.php?price_range[]=1-10&price_range[]=21-30 in my URL Can I now use in_array or something to see if 21-30 was passed in price_range?
  7. Thanks slurpee, but I want to be able to pass in more than one price range because the ranges could be 10-20, 50-60. Can I do something like that?
  8. Hi, I want to be able to test if a particular price range was passed in the URL. The URL I'm passing is www.myurl.com?Price_Range=10-20&Price_Range=20-30 I've tried using something like this if(isset($_GET['Price_Range']['10-20'])) echo 'found it'; But it didn't work. Is there a way I can check for a value passed in the URL given the key is 'Price_Range'? Thank you
  9. Thinking about this a bit more, should I always display my form by using data from $_POST if there is any data, and if there is no data only then display the form by reading from the database? This would reduce server load I think? So, before I display my form I would check to see if there was anything in $_POST and if there is, use that data to build my form, otherwise read the data from the database. Is that the best way to do it?
  10. Hi all! I'm trying to learn php and am struggling with validation. I'm not sure whether it's best to use php or javascript, but I thought I'd try using php given I'm trying to learn the language Can you help me with the following problem I have? I have a list of surnames read from a database and displayed in an html table using this loop: while($row = db2_fetch_assoc($numresults)) { if (is_int($count/2)) { echo '<tr class="even">'."\n"; } else { echo '<tr class="odd">'."\n"; } echo '<td><input style="width:300px;" name="surname[]" value="' . trim($row['SURNAME']) . '" type="text" maxlength="30"><input type="hidden" name="rrn[]" value="' . $row['RRN'] . '"></td>'."\n"; echo '</tr>'."\n"; $count ++; } The hidden RRN field is a unique key to the database record. When the user makes changes and hits submit I validate and update using this loop: if ($_POST['update'] == 'Update') { foreach (array_keys($_POST['rrn']) as $key => $val) { $surname = $_POST['surname'][$key]; /* Name cannot be blank */ if($surname == ''){ array_push($message, 'Name cannot be blank'); } } /* Display error */ if(!empty($message)){ echo '<div class="messageStackError">'; foreach($message as $value){ echo '<img src="/images/error.gif" alt="Error" title="Error" width="20" height="20" />'; echo $value; echo '<br />'; } echo '</div>'; echo '<br />'; } /* Update if no errors */ if (empty($message)) { /* UPDATE THE DATABASE */ } } When the user updates one of the surnames and hits the 'Update' button, the form submits itself. It goes through the validation loop and displays any error messages, then redisplays the form. This all works great, but I'm wondering if there's a way to highlight the particular name in the list that is in error rather than just display the error message in the messageStackError <div> as I am doing. The other problem I have with my approach is because the form redisplays each time, any invalid entries disappear because the data is being read back from the database. Is it good practice to do what I'm trying or should I be using javascript to validate? Thanks for your help!
  11. Hi, I have some php code to detect if a browser has the flash plugin. It works great in Fire Fox but in Internet Explorer 8(I haven't been able to test in other versions yet) it doesn't work on entry to my site, but if you hit refresh it suddenly works Here's a link to my test site so you can see what I mean: http://snow.byethost8.com/shop/ When you first go in, right click the main image and you'll see it's an image because you get the 'Save picture as' option. Now hit refresh and do the same thing.....it's now flash! Is there a better way to detect flash using php? Here's the code I'm using: <?php // Search through the HTTP_ACCEPT header for the Flash Player mime-type. $swfheader = strpos($_SERVER['HTTP_ACCEPT'],'application/x-shockwave-flash'); if($swfheader === false) { $hasFlash=true; } else { $hasFlash=false; } ?>
×
×
  • 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.