Jump to content

henryhenry

Members
  • Posts

    75
  • Joined

  • Last visited

Everything posted by henryhenry

  1. Second this suggestion. The oop is pretty confusing and it would be really great to get a nice tutorial on w3schools which clears it up a bit.
  2. I had a nightmare with mod_rewrite...here are more tutorials + cheat sheet I found...http://www.crucialp.com/resources/tutorial...with-apache.phphttp://www.ilovejackdaniels.com/apache/mod...te-cheat-sheet/http://articles.techrepublic.com.com/5100-...11-5068743.htmlI finally got it working after posting on here...http://groups.google.com/group/alt.apache....n/topics?lnk=lrHope it helps Henry
  3. I really have to say, if you don't already use it then install the firefox developer tools now! It really is a dream for CSS. For example, today I discovered that it can tell me all the CSS styles applied to a particular element - even ones set by the browser - so no more guessing what is causing an annoying div to be out of place!!! Such a relief! Anyway... I only just discovered it and thought I'd share - it really is incredibly useful.Here it is: https://addons.mozilla.org/en-US/firefox/addon/60Does anyone know about anything equivalent for IE (or Opera?)Henry
  4. HiI'd forgotten about this...hopefully you guys are still there to help me out Thanks!It's a bit of a theoretical question right now as I gave it a bit of a try and didn't manage it so I changed my approach. But I think it would be useful for a few things.A simple example would be:I have a heading stored in my database eg:This page is about {$title}But I want to use the same entry in the database to populate 5 pages with the following titles:This page is about SurfingThis page is about DivingThis page is about BodyBoardingThis page is about SwimmingThis page is about LivingSo the entry in the database doesn't record the actual value of $title but when you insert that entry into the page, you it would THEN look for $title and assuming it's set, then heading would alter accordingly.Hmmm... perhaps variable variables is the way forward but I can't quite see how that would do it...any thoughts?ThanksHenry
  5. Hi Mr ChisolThanks for the prompt. The solution was something like that...I had been fiddling with the php rule and the slashes went at some point although I think I had them before! I put them back first...In my javascript I was using the test method but I found that setting the reg ex as a string and using match worked properly (using the slashes on the string) while the test method was still letting through x@y.I really don't like javascript!!!
  6. Here is my reg exp:^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$It is for checking emails. I have taken from the site http://regexlib.com - thanks!Oddly enough in javascript, the following validates: henry@henry ... But in PHP it doesn't.I'm thinking - 1. my reg exp is wrong (shouldn't) 2. my javascript is dodgy 3. my php is dodgy 4. php and javascript handle reg exp differently?Any ideas?ie - here's my php: $rule= '"^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$"'; if (!preg_match($rule, stripslashes(trim($a_email[$i])))) { $a_errors[]= 'The email address entered is not valid.'; } else { $v_email[$i]= escape_data($a_email[$i]); } and here's my java script: var filterEmail= new RegExp("^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$"); if (filterEmail.test(inputValue)) { window.formValidity[instance]='valid'; } else { window.formValidity[instance]='invalid'; } Thanks as ever!Henry
  7. Hello!Does anyone know a technique to store a reference to a variable in MySQL?I want my table to hold the name of the variable - eg $varThen I want my page to take the name and get the value from the other part of the page...eg$var="hello world"then later in the page...query result would be: "This is an interesting $var"If you print the query result to the page you would see on the final page: "This is an interesting hello world"Is this possible? Maybe it's more of a PHP question - not sure?ThanksHenry
  8. henryhenry

    page refresh

    HelloYes it was primarily insert/update/delete - I am using software to make tables/columns...The cookie method sounds perfect! I will definitely be giving that a try! Thanks once again! This forum is sooo helpful!Henry
  9. henryhenry

    page refresh

    I have a bit of an issue with refreshing pages...When you hit refresh, the script resends any SQL queries to the DB (the page is handled on the same page). This is particularly annoying on a form with INSERT queries.I have tried the following (which work but aren't great)- look up data and compare before the insert/update- make columns unique in database- redirect using headers() but can be a pain if 'headers already sent'I would love just to use a simple variable to tell me if the page was refreshed and if so not to run queries! Does anyone know a trick that can make this work?Thanks!Henry
  10. The way I learnt to do this was to use a hidden input <input type="hidden" name="submitted" value="TRUE" />Then outside your form you have a conditional a bit like...if (isset($_POST['submitted'])) { $miles = $_POST['miles']; $speed = $_POST['speed']; $result = $miles + $speed; echo $result; }maybe you don't need this conditional but it seems to work for me You definitely need to switch GET for POST if you use method="post" though...maybe that's where the error is.Also if you want to keep the values in the form fields after submitting then you can use a conditional inside the value=" " in the form itself:...value="<?php if(isset($_POST['miles'])) { echo $_POST['miles']; } ?>" ...That way, when you click submit, the value from the $_POST array is entered into the value=" " but when the page first loads it is just empty.Well I'm not sure if that helps but that's what I do
  11. HiSort of - maybe... I know how to get the normal form fields to retain their values but I can't make it work an upload field <input type="file" />. Can you use javascript to make this one maintain a variable?
  12. Can you get a file input to be sticky (ie when you hit refresh or submit the value in the $_POST (or $_FILES?) array is still displayed). I have read somewhere that browsers prevent this but I could swear that I've seen it done somewhere!
  13. henryhenry

    Loop

    This is something like what I do for the query so that you only have one query and not loop the query itself but the values inside it... $cols= array(..., ..., ..., ....);$data= array(..., ..., ..., ...); // or you can use the methods described above to get your form data into an array (name="text[]" automatically gives you an array) $query= "INSERT INTO $table ("; foreach ($cols as $v) { $query .= "$v, "; } //Get each $cols (this is an array of the column names in the same order as your data $query= substr($query, 0, -2); //This removes the final ', ' which is added in the loop $query .= ") VALUES ("; for ($i=$start; $i<=$end; $i++) { $query .= "'".$data[$i]."', "; } //this puts data from the data array $query = substr($query, 0, -2); //remove the last ", " from the loop again $query .= ")"; //add the last ) to the VALUES ( ) to finish the query Then I use this as a function and all you do is set the column names and a few parameters and hey presto :)Don't know if that helps but it works for me!
  14. Thanks once more!mod_rewrite is exactly what I was looking for. sometimes you have to wonder about google - you search for what seems obvious and NOTHING It's all about knowing the language!getting mod_rewrite to work is another story of course! but I'm working on that!Henry
  15. I want to have nice user-friendly urls but I have a few challenges. Bear with me here - I'm still learning so there may be some very obvious errors!I have different pages categorised a bit like this:group x - category 1 - product a - product b - category 2 - category 3group y - category 2 - category 3group z - category 3 - category 4 - category 5etc etc. Some things come under multiple headings. I want to have the URL a bit like www.test.com/groupx/category1/producta.phpMy current plan is to have a set of empty folders. Then when you load the URL, I have my script take the URL as a string and cut it up getting the group, category and product names, then look up primary keys on my DB. Then I get PHP to copy the producta.php into the empty folder while it's being used. Finally, after the user leaves the page, the file copy is deleted, leaving an empty folder again.Is this a crazy way to do this? I have searched quite a lot without much success in finding a method.Thanks as ever!
  16. OK - you lost me slightly with the stacks and everything but the message seems to be don't worry about performance by calling functions but try to avoid using them in loops if possible. Thanks for your advice!
  17. Hi Xenon DesignThanks for the great solution! I can see it works!Unfortunately everything is against me today so it's not working on my actual page yet ... but the solution obviously works - I'm just having a bad day!Henry
  18. henryhenry

    inline :hover

    Hello!I am trying to define a :hover pseudo class inline. The reason is that I have a php script for a menu and I want the little arrows to display only if there is another level to the menu and then to change colour when hovering over the item. All works except for the hover. The problem is I can't define the :hover in the css external file because it has to be conditional. If I put a <style> tag even just after the <a> tag it applies it as if I'd put it in the <head> (ie to the whole page rather than just the part I want).Is it possible (prefer no javascript)?Thanks!!Henry
  19. cssplay.co.uk is great.I also used www.positioniseverything.net - here is the working example http://www.positioniseverything.net/css-dropdowns.html
  20. What's wrong with setting the margin of the inside div as 50% on top and bottom? Works in Opera 9 & FF2 & IE6If you want relative width on the inner div you have to be careful with O9 and IE6 which seem to recalculate the width using the container width minus the margin (ie (200px-25%)*x% as opposed to just x%)But then maybe you've tried this - couldn't really tell... <div style="width: 200px;height: 400px;border: 1px solid black;"><div style="width: 100px;height: 50%;background: gray;margin-top: 50%;margin-bottom: 50%;margin-left: 25%;"></div></div>
  21. Thanks Mr Chisol. Very helpful! I'm going to continue as is - actually making more complex structure now as I am really keen on well ordered and structured information!
  22. I am trying to make my code a bit 'cleaner' and I am making useful functions out of things and then putting them in a nicely organised seperate 'function.php' file which I include on every page.I am a bit concerned that this may slow things down though especially as I'm using SQL in the functions. Right now it's not noticeable on my local machine (using localhost - apache). I have no real experience so I'm not sure if I'm going to regret this functions.php later? Is it better to put functions on the page itself or store in an include file? And is it better to use functions or to have the 'plain' code sitting in the page...Anyone have any guidance/experience - what do you do with functions?
  23. Yeah - hello on the left and world on the right...Have styled the select - that seems to work... Perhaps I will resort to using ?!
  24. I've found www.positioniseverything.net very helpful for layout and nice CSS tricks... - not 100% sure if it has what you need...Also with some great examples is www.cssplay.co.uk
  25. I'm not sure if this is a bit hopeful...oh and this may be more of an HTML/XHTML question but also concerns CSS... Maybe there is a CSS solution without additional tags?<form> <select> <option>Hello <span><em>World</em><span></option> <option>Hello World</option> <option>Hello World</option> <option>Hello World</option> </select></form>I have one piece of data 'Hello' from one table on my DB and one piece of data 'World' from another. It is a list of categories with the description of the category. I have tried putting tags into the option/select so I can use CSS to align the 'World' part to the right and make it italic. But I have not had any luck ... any ideas?Thanks in advance :)Henry
×
×
  • Create New...