Jump to content

ToonMariner

Members
  • Posts

    3,342
  • Joined

  • Last visited

Everything posted by ToonMariner

  1. I'm not to comfortable with the form posting data to a url with parameters in it. Why not just have pots data going to that script? simply add a hiden field like so <input type="hidden" name="mode" id="mode" value="add_comp_cat" />
  2. $_GET[] is an array of data sent to the current script from the previouse html page via the get method header (when the method of your form is method="get". Same for $_POST[] but form method="post" $_REQUEST[] is an array containing values from either of these methods - I do use it sometimes but very rarely....
  3. yes... I suggest you look at 'switch' and header('Location: http://www.asite.com');
  4. yep... add the variables that were set to the links of your pagination.... so they will say <a href="yourscript.php?s=10&business_name=" . $_GET['business_name'] . "&state=" ..... and so on.
  5. OK to mimic that using an array.... $arr = array(1,3,4,7,9); $newrow = 4; $size = count($arr); $arr[$size] = NULL; for($i=$size;$i=$newrow;$i--) { $arr[$i] = $arr[$i-1]; } $arr[$newrow - 1] = NULL; I think that could do it.
  6. You don't mimic tables with divs!!! ;) Tables are for information - so don't use them for layout. [url=http://www.w3.org/2002/03/csslayout-howto]http://www.w3.org/2002/03/csslayout-howto[/url] a reasonable starting point.
  7. I don't want you to do anything - but It woud most certainly help you in the long AND short run.
  8. LOL Suggest you cahnge it now - it will save you lots of time hassel and not to mention a significant amount of disk space in the not too distant...
  9. read this [url=http://www.phpfreaks.com/tutorials/43/0.php]http://www.phpfreaks.com/tutorials/43/0.php[/url]
  10. Sorry my friend but I'm not quite getting that. I have never done it but I am not sure whether inserting a NULL element into an array will work - it probably will. BUT can't really see from that code what you're trying to insert and why you need to.
  11. [code] <?php $qry = mysql_query("SELECT * FROM productcategories_comp ORDER BY name ASC"); $cats = array(); while($row = mysql_fetch_assoc($qry)) { foreach($row as $key => $val) {   $cats[$key][] = $val; } } $qry = mysql_query("SELECT * FROM products WHERE parent='$parent' ORDER BY id DESC"); $products = array(); while($row = mysql_fetch_array($qry)) { foreach($row as $key => $val) {   $products[$key][] = $val; } ?> [/code] that generates two (potentially massive) arrays of categories and products. BUT before I go on I need to know your table structure. Are you creating a new record for each item in the products OR (and better to do) are you storing one record for each product and having a field in that record of how many you have in stock?
  12. You have a while loop to assign product number - it will only ever assign the ID of the product not the number in stock and there will only ever be 1 record so no use using a while loop there! The methdo you use is at risk because you generate a query within a loop and many servers are set up to limit the number of queries per script to 50 (depending on the settings for teh user the script belongs to) so you could hit trouble there at some point. This I think is one of those where you must extract ALL the info from each table and put it into an array. Then use hash tables to grab the bits you need out of each array.
  13. $stop = count($_SESSION['jobcode']); for($i=1;$i<=$stop;$i++){   $_SESSION['job_code'][$i]=$_SESSION['job_code'][$i-1]; } or you could simply use array_shift($_SESSION['job_code']) - this will remove teh first element of the array and of course make the array one element smaller.
  14. OK well firsat lets get you query string generation a bit more efficient... [code]<?php $qry = "SELECT * FROM Users WHERE "; // start of string $sub = NULL; //initialize substring if (isset($_GET['business_name']) && strlen($_GET['business_name']) > 0) { $sub = "Business_Name LIKE '%" . $_GET['business_name'] . "%'"; } if (isset($_GET['category']) && strlen($_GET['category']) > 0) { $sub .= is_null($sub) ? " Category = '" . $_GET['category'] . "'" : " AND Category = '" . $_GET['category'] . "'"; } if (isset($_GET['state']) && strlen($_GET['state']) > 0) { $sub .= is_null($sub) ? " State ='" . $_GET['state'] . "'" : " AND State ='" . $_GET['state'] . "'"; } $limit = 10; $s = empty($s) ? 0 : $s; $qry .=  $sub . "ORDER BY Business_Name, City LIMIT $s, $limit"; // end of string ?>[/code] Now that may look a little daunting but read it a couple of times and it will make sense.... try that and see how you get on
  15. What???????? SELECT * FROM products WHERE parent='$parent' ORDER BY id DESC LIMIT 1 Will do this. 1. Select every field from products where parent=$parent. 2. Order the results by id in descending order. 3. Limit the number of results retured to 1 result. if you want to know the number of items you can either do $qry = "SELECT * FROM products WHERE parent='$parent'"; $qry = mysql_query($queyr); $num = mysql_num_rows($query); or use the COUNT in the query itself. SELECT COUNT('id') FROM products WHERE parent='$parent' The latter being more efficient UNLESS you are going to use all the information in the table then use teh former query.
  16. td.resulttab1, td.resulttab2 {   height: 20px;   width: 100px; } td.resulttab1 {   background-color: #FFCC66; } td.resulttab1 {   background-color: #FF9933; }
  17. You should really design a site for 800px wide (I use 765 - it looks nicer!) or % - thats if you are going to do it properly ;)
  18. toughie to answer!!!! it depends on what you are using the col and row spans for! if this is just layout and something like a nav menu on the left then simply place your nav in a div and float it to the left.
  19. the where clause should come BEFORE teh order by clause
  20. jvalarta..... The cron job IS your answer.... you can set an infinite loop in a script in a cron job too! but really - what is wrong in doing something where a cron job kicks off every minute, the loop is... for($i = 0 ; $i <3 ; $i++) { whatever your code is sleep (20); } that loop will run once every 20 seconds (so in 1 minute it will execute at 00 20 and 40 seconds only to be restarted at the begining of the next minute). Unless your data feed is lost the instance it gets to you (that is stupid and if so even an infinite loop will more than probably miss something!!!) then there is no detectable difference to the user whether it picks up data every nanosecond or every 20 seconds. Setting the cron job will leave this process running until you kill it manually - it is NOT dependant on a browser window being open..
  21. you can just do a preg_replace on the string..... look for patterns (or regular expressions) like so.... $lookfor = array( '/(s|5)hit/', '/(ph|f)uck/', '/a(s|5){2}/' ); $message = preg_replace($lookfor, '****', $message); still requires a bit of vigilance BUT if you keep at it for a while you have a killer profanity filter........
  22. It appears register globals is off (which is good!) try: $title = isset($_POST['title']) ? addslashes($_POST['title']) : NULL; $text = isset($_POST['text']) ? addslashes($_POST['text']) : NULL; if (is_null($title) || is_null($text)) { exit("You didn't completely fill in the form!"); } ....
  23. Hi People. Despite coding for a few years now I am about to embark on my first e-commerce site! Now before I go trawling through the documentation I would like to request any comments on the 'best' options to follow. To date I have only looked at using curl but are there other suitable methods? Also could you please comment on the pros/cons. Many thanks people.
  24. read all the entries from the file into an array. Then traverse the array in a loop with limits on(start at and stop at) you will then limit the number of entries displayed. Send these limits via the url (page.php?start=75&amp;stop=100) and you should be fine. Remember to initialize start and stop incase they are not set!!!!
×
×
  • 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.