Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Everything posted by HuggieBear

  1. [quote] Obviouslly in the URL id?=1?page=2 wouldn't work, if it did how do I call it twice in my PHP? [/quote] Use '&' to pass additional parameters [code] mypage.php?id=1&page=2 [/code]
  2. Sorry, How many months between January 2005 and September 2006. The months will be between whole months, not particular dates. Rich
  3. What's the easiest way to work out the number of months between two dates? I've been looking at the date() and time() functions and can probably figure out a way to work it but wondered if their was a function already? Regards Rich
  4. You could use two queries. I'm not writing actual code, so don't come back complaining about syntax, just want to give you an idea... [code]SELECT distinct(setnamelong) FROM vids ORDER BY setnamelong foreach ($setnamelong as $setname){   echo '$setname'   SELECT * FROM vids WHERE setnamelong = '$setname' ORDER BY title   while ( ... ){       // then your existing echo loop here   } }[/code] What do you think feasible? Rich
  5. As you edited your post to include how you'd create the HTML for it, I'll have a stab at that too... Lets say that you're information is going to be displayed on productdetail.php which is passed the ProductID in the URL from a previous page. [code] <?php if (!isset($_POST['ProductID'])){   header('Location: home.php'); // Lets redirect our users if they enter our page without a ProductID. } else{   $ProductID = $_POST['ProductID'];   include("connect.php"); // Include your connection strings in this seperate file   $query = "SELECT Size FROM Sizes WHERE SizeID IN (SELECT QSizeID FROM ProductQuantity WHERE QProdID = '$ProductID' AND Quantity != 0)";   $result = mysql_query($query); // Execute the query   if (!$result){       die('Could run query: ' .mysql_error());   }   while ($sizes = mysql_fetch_array($result, MYSQL_ASSOC)){  // While there are still rows, do this ...       $option[]=$sizes["Size"]; //push the rows into a new array (we can do this as we know we're only selecting one column)   }   echo "<select name=\"sizes\">";   foreach ($option as $size){       echo "<option value=\"$size\">$size</option>\n"; // echo each individual item in the $option array   }   echo "</select>";   include("disconnect.php"); // Include your disconnect details in a seperate file } ?> [/code] This should give you the values in a drop down list. Rich
  6. Maybe another table similar to this: [table] [tr][td][b]ProductQuantity[/b][/td][/tr] [tr][td]QuantityID[/td][td]QProdID[/td][td]QSizeID[/td][td]Quantity[/td][/tr] [tr][td]1[/td][td]4[/td][td]10[/td][td]1[/td][/tr] [tr][td]2[/td][td]4[/td][td]11[/td][td]1[/td][/tr] [tr][td]3[/td][td]1[/td][td]4[/td][td]6[/td][/tr] [tr][td]4[/td][td]1[/td][td]5[/td][td]3[/td][/tr] [tr][td]5[/td][td]1[/td][td]6[/td][td]3[/td][/tr] [/table] I'm not sure this is 100% effecient, but it should work.  QuantityID is another unique value, QProdID is linked to your ProductID in your product table, QSizeID is linked to SizeID in your Sizes table and quantity is the amount you have. That way you could only display the sizes of what you have in stock.  Some SQL something similar to this... [code] SELECT Size FROM Sizes WHERE SizeID IN (     SELECT QSizeID     FROM ProductQuantity     WHERE QProdID = '$ProductID'     AND Quantity != 0) [/code] $ProductID is the variable passed from into the search from PHP. I'm sure some DB experts could point you in a better direction, but this should work. Rich
  7. Id go for something like this... [table] [tr][td][b]SizeType[/b][/td][/tr] [tr][td]SizeTypeID[/td][td]ChartName[/td][td]Description[/td][/tr] [tr][td]1[/td][td]UKSHOE[/td][td]UK Shoe Sizes[/td][/tr] [tr][td]2[/td][td]EUROPESHOE[/td][td]European Shoe Sizes[/td][/tr] [tr][td]3[/td][td]UKMALEWAIST[/td][td]Male waist size UK[/td][/tr] [tr][td]4[/td][td]UKFEMALESKIRT[/td][td]Female skirt size UK[/td][/tr] [tr][td]5[/td][td]UKMARKET[/td][td]Standard UK Market size[/td][/tr] [/table] [table] [tr][td][b]Sizes[/b][/td][/tr] [tr][td]SizeID[/td][td]SizeChartID[/td][td]Size[/td][/tr] [tr][td]1[/td][td]1[/td][td]8[/td][/tr] [tr][td]2[/td][td]1[/td][td]9[/td][/tr] [tr][td]3[/td][td]1[/td][td]10[/td][/tr] [tr][td]4[/td][td]2[/td][td]42[/td][/tr] [tr][td]5[/td][td]2[/td][td]43[/td][/tr] [tr][td]6[/td][td]2[/td][td]44[/td][/tr] [tr][td]7[/td][td]3[/td][td]38[/td][/tr] [tr][td]8[/td][td]4[/td][td]10[/td][/tr] [tr][td]9[/td][td]4[/td][td]12[/td][/tr] [tr][td]10[/td][td]5[/td][td]S[/td][/tr] [tr][td]11[/td][td]5[/td][td]M[/td][/tr] [tr][td]12[/td][td]5[/td][td]L[/td][/tr] [tr][td]13[/td][td]5[/td][td]XL[/td][/tr] [/table] This is your existing product table... Just add a 'size' column linked to the UniqueID of the SizeType table [table] [tr][td][b]Product[/b][/td][/tr] [tr][td]ProductID[/td][td]Name[/td][td]Size[/td][td]Colour[/td][td]Price[/td][/tr] [tr][td]1[/td][td]Nike Air Max[/td][td]1[/td][td]Red[/td][td]35.00[/td][/tr] [tr][td]2[/td][td]Nike Air Zoom (US)[/td][td]2[/td][td]Blue[/td][td]40.00[/td][/tr] [tr][td]3[/td][td]Silk Skirt[/td][td]4[/td][td]Black[/td][td]22.00[/td][/tr] [tr][td]4[/td][td]Mens Cargo Trousers[/td][td]3[/td][td]Khaki[/td][td]37.00[/td][/tr] [/table] You can add an additional table in there for specific product sizes.  e.g. if Nike Air Zoom (US) only come in size 43. Regards Rich
  8. You could use a regular expression: [code] if (preg_match("/^(12345|54321)/", $_GET['field_name'])){   //do something here } else {   // ... } [/code] Should do it. In fact you could use a RegEx for the whole thing.  Lets say your field has to have 9 characters, not be null and start with either 'email' or 'phone' [code] if (preg_match("/^(email|phone)\w{4}/", $_GET['field_name'])){   // It's fine... } else {   // show me an error... } [/code] Regards Rich
  9. I think this is an interpolation question but I'm not sure. I have the following code, now I know the code's not ideal, but I'm putting it like this so I can learn. [code=php:0] <?php $fruit = $_GET['fruit'] // The value of 'fruit' is going to be a text string passed from a form of either "$apple" or "$grape" $apple[]="red"; $apple[]="green"; $grape[] = "purple"; $grape[] = "green"; foreach ($var as $colour){ // how can I make $var whatever the value of $fruit is I guess I need to interpolate the variable   echo $colour; } ?> [/code] I hope this made sense. Regards Rich
  10. Thanks Wildteen, pointed me in the right direction. I found the info in the documentation [url=http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server]here[/url].
  11. [quote] HuggieBear... the only change I made was "I took out the '!'"... because I want them to submit if there is an ip address. You got me 99% over that hurdle (I have to do some thinking for myself)... thanks so much! [/quote] Sorry about the '!' I misread the code...  :o Glad you picked up on it though  :)
  12. Where can I find information in the PHP documentation about !_SERVER[...] variables? I've searched and can't find anything.  According to phpinfo() they come under the Apache heading, but I can't find anything under the 'Apache specific' functions in the manual. Regards Rich
  13. [quote] I added what another snippet to my if statement before my insert code: if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "malta_add") && ($_SERVER['REMOTE_ADDR'] != "")) {....... Have I written this wrong?  Shouldn't that addition have stopped a post if there was no value for $_SERVER['REMOTE_ADDR'] [/quote] You could try this: [code] if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "malta_add") && (!$_SERVER['REMOTE_ADDR'])) {....... [/code] I think this should work if $_SERVER['REMOTE_ADDR'] is empty. Rich
  14. [quote] Hi HuggieBear, there is a little problem in ur solution. Remember, search string (e.g. "red" i use here) is inputed by the visitor in the website. Now if there is a record which looks like ==>[font color=green]this is red[/font] the search for "red" will not return this record [/quote] How right you are... Good spot  :-X
  15. Correct, but you won't get the rest of the string, you realise that right? Richard will yield RIC not RIChard. Regards Rich
  16. A note that's very important when using regular expressions is the following quantifiers: [color=red]*[/color] means 'Zero or more' [color=red]?[/color] means 'Zero or one' [color=red]+[/color] means 'One or more' And the reason that Obsidian has added the [color=green]+[/color] at the end of the character class [color=green][a-z0-9][/color] is to indicate that there must be some data entered, had he have put the following: |^[a-z0-9][b]*[/b]$|i Note the * instead of + Then an empty string would be considered as valid. Rich
  17. The [color=red]|[/color] are the delimeters the [color=red]^[/color] matches start of line the [color=red]+[/color] matches one or more of the previous characters/classes (in this case classes) the [color=red]$[/color] matches end of line Rich
  18. Obsidian, You need to remove the additional 'http://' in the 'RegEx' link in your signature.  Just tried to get there  :) Rich
  19. In Perl I'd use a regex to check that the field only contains Alpha-Numeric characters.  I'm sure php is capable of the same, but it may have a better function for it. I'll look into this now. Rich
  20. Sorry, was just trying to avoid inserting almost identical data into two seperate columns. Rich
  21. Are you writing your own BB system or modifying an existing one? If you're writing your own, then why not use PHP to veryify the input at the time of insert into the database? You could use a regex to search for BBCode and then insert into a new column in the database named 'bbcode' either TRUE or FALSE. Then when you search, just use... [code] $result=mysql_query("SELECT * FROM table_name WHERE bbcode = 'TRUE' AND column_name LIKE '%red%'"); [/code] Regards Rich
  22. If you know the file only contains one line, then best to use file_get_contents() as per Jenk's post. This will return the contents of the file in a string as opposed to an array. Rich
×
×
  • 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.