Jump to content

scottybwoy

Members
  • Posts

    532
  • Joined

  • Last visited

    Never

Everything posted by scottybwoy

  1. That is the answer you have come up with. Well done.
  2. Is it possible to have a query within a query? Let me expand... I have a table of categories and a table of products that belong to the categories. In the table of categories there may be child categories. Usually the parent category doesn't have products in it, but just child categories within the same table. The structure is like this to keep it simple I will just show the relevant fields : | categories_id | parent_id | ===================== | 29 | | | 30 | 29 | | 31 | 30 | | 32 | 30 | ... And the other table is just as simple : | product_id | category_id | ===================== | 21 | 31 | | 22 | 32 | | 23 | 31 | ... So is it possible to have a single query that can take a category_id, lets say 29 in this example, discover whether it is a parent, if so does its child have a daughter (this loop recursive until the category has no children) Then retrieve all the product_ids for it? Hope that makes sense? Thanks
  3. lol, cheers, I didn't think it was that simple. Is there a better way of going about this code anyway. Thanks
  4. " " allows you to put in $variables and will see them fine. If you use ' ' you will have to concatenate your variables and array values using (.). However when you use " " it will not see your array key as it will treat ' ' as normal characters. But I think I've just learnt from kenrbnsn that you can use { } to make php see the $array['key'].
  5. Do you know any php or html as some knowledge will be know to help you do this. First you need to set up a simple form to put in the post code you want to compare. Then you need that to send the data to your script file using POST/GET. You will need to specify, what other post code you want to compare it. All the code that was provided in that blog can sit in one file. Try that first, then ask if you need more help. Good Luck
  6. Hi people, I've gone blind at the sight of my own ugly code. I can't see why it get trapped in a loop + there must be a better way of writing code (sorry it's a bit long ). Any pointers would be great. if ($number_of_categories > 2) { $limit = 1; } else if ($number_of_categories == 2) { $limit = 2; } else { $limit = 4; } $sql = "SELECT * FROM `categories` WHERE `parent_id` = " . $categories['categories_id']; $qry = mysql_query($sql); if (mysql_num_rows($qry) > 0) { static $i; $i = 1; while (($cat_row = mysql_fetch_assoc(mysql_query($sql))) && ($i <= $limit)) { $n2_sql = "SELECT * FROM `categories` WHERE `parent_id` = " . $cat_row['categories_id']; $n_qry = mysql_query($n2_sql); if (mysql_num_rows($n_qry) > 0) { while (($n_cat_row = mysql_fetch_assoc($n_qry)) && ($i <= $limit)) { $n2_sql = "SELECT p.products_id, p.products_model, p.products_image, p.products_price FROM products p INNER JOIN products_to_categories ptc ON ptc.products_id = p.products_id WHERE ptc.categories_id = " . $n_cat_row['categories_id'] . " AND p.products_status = 1 ORDER BY p.products_ordered DESC LIMIT 1"; $n_cat_prod_row = mysql_fetch_assoc(mysql_query($n2_sql)); $info_box_contents = array(); $info_box_contents[] = array('text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $prod_row['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $n_cat_prod_row['products_image'], $n_cat_prod_row['products_model'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br />' . $n_cat_prod_row['products_model'] . ' > £' . number_format($n_cat_prod_row['products_price'], 2) . '</a>'); new infoBox($info_box_contents); $i++; } } else { $n_sql = "SELECT p.products_id, p.products_model, p.products_image, p.products_price FROM products p INNER JOIN products_to_categories ptc ON ptc.products_id = p.products_id WHERE ptc.categories_id = " . $cat_row['categories_id'] . " AND p.products_status = 1 ORDER BY p.products_ordered DESC LIMIT $limit"; while ($n_cat_prod_row = mysql_fetch_assoc(mysql_query($n_sql))) { $info_box_contents = array(); $info_box_contents[] = array('text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $prod_row['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $n_cat_prod_row['products_image'], $n_cat_prod_row['products_model'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br />' . $n_cat_prod_row['products_model'] . ' > £' . number_format($n_cat_prod_row['products_price'], 2) . '</a>'); new infoBox($info_box_contents); } $i = $limit + 1; } } } else { $sql = "SELECT p.products_id, p.products_model, p.products_image, p.products_price FROM products p INNER JOIN products_to_categories ptc ON ptc.products_id = p.products_id WHERE ptc.categories_id = " . $categories['categories_id'] . " AND p.products_status = 1 ORDER BY p.products_ordered DESC LIMIT $limit"; $qry = mysql_query($sql); while ($prod_row = mysql_fetch_assoc($qry)) { $info_box_contents = array(); $info_box_contents[] = array('text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $prod_row['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $prod_row['products_image'], $prod_row['products_model'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br />' . $prod_row['products_model'] . ' > £' . number_format($prod_row['products_price'], 2) . '</a>'); new infoBox($info_box_contents); } } ...Thanks superior coder
  7. Thanks Obsidian for pointing me in the right direction.
  8. OK, I am familiar with JOIN AND WHERE, but not together. I have two tables; one with product_ids and category_ids, and one with all the product details. I want to select all product_ids for a specific category_id and filter the results based on data from the second table. Here's MyPsudo statement that I need help with : SELECT products.products_model, products.products_image, products.products_price RIGHT JOIN ON products_to_categories.products_id = products.products_id WHERE products_to_categories.categories_id AND WHERE products.products_quantity > 0 AND WHERE products.products_status = 1 ORDER BY products.products_ordered DESC LIMIT 1 Thats probably really basic, I'm only just beginning to do more complex queries so please bear with me. What would be the correct syntax for that statement above, I hope it makes sense. Cheers
  9. Cheers GuiltyGear, My problem is no longer with IE 6/7, on my development machine it seems to be displaying as it should for both. However it only seems to be apearing correctly for the front page in Firefox 3. I used the code from that page you sent but it does not correct the issue. It displays fine in FF2. FF3 sems to display it differently for each page, even tho the html markup is the same and so iss the css? Any ideas?
  10. Ok I have installed FF3 and IE7, I think it should now work in Ie7 (does on mine), but I thought that FF2 and FF3 would be quite similar, but I do have that behaviour (left menu disappears to the left) in FF3. Does anyone know how to get the "A List Apart - Holy Grail" to work in both ff2 & 3?
  11. Well done, for shedding the light on that one GuiltyGear. By the way that sites great! I now have both versions running and can do much more testing, I wish I found it before going live . However, does the standalone version not support sessions? Are their any settings for this?
  12. Thanks for that GuiltyGear, will install that now. I agree, we do have Vista on a machine downstairs, but XP is less bulky for general web building. Also my input fields are already using % widths. The reason why it has mixed <divs> and <tables> is because I used OsCommerce, which is pure tables. I know tables are evil, which I why I switched most of it to <divs> but it's template engine is a bit complex and I didn't go so far as to change that bit. Thanks for all your help any way. But do keep the suggestions coming.
  13. Well I am using IE6, so I know it works fine in that. What is the best way to dual install IE6 and 7? I read that you can with some registry changes, but apparently it does effect how IE6 and 7 work. Another way was to run a virtual machine, but that seems really long winded. Any other ideas? I have not actually looked but can u run FF2 & 3 together as I have some really helpful plug ins that I will lose in FF3. Thanks for your help.
  14. Great Idea, and nice simple site. Most of my knit bits have already been stated, but I think the content of the pages should be extended to the width of your top-nav bar. The rest of my quarms are just down to some of the styling. I don't like the font used under Code Kindness header, maybe opt for a smoother rounded one. The red links within the black body text, although in line with your theme, maybe make it a bit darker and richer, for instance I think #c00 might be good, or one closer to f @ the beginning. On the How It Works page, the small bold text is hard to read and needs a bit more contrast, I would definitely make it a bit bigger, nice font tho. And lastly on the requests page, I would separate the rows a bit more, and maybe have alternating colours <- probably a colour from your sign up form. All in all tho, good luck.
  15. Hi peeps, I have set up an eCommerce site, but some customers have been having trouble setting up an account. In IE7 apparently some users receive readonly input fields. Others mention that the whole form has a stupidly wide width, that makes them have to scroll. Can people please have a poke around, in particularly the account area, and let me know if you receive these same issues, what browser and resolution you are in, and possibly how to fix it. www.klickshopping.co.uk Thanks, any other critique welcome.
  16. Is their an optimum number of keywords you should use? Is it best to mix and match, broad, strict and unique phrases? How do these best draw in customers?
  17. Hi, As the title suggests, that's what I want to do. However I don't know if my web pages are built for it to work effectively. In the top section of the php page, I define 3 $vars; $title, $desc, $keywords. Then I call my header file, that has the correct placements for them. Down the rest of the page, I use static <h> and <p> elems, which would build up my content; titles, descriptions, and list data. Do keyword suggestion tools use the generated content of files? If so, why do the ones I've tried, yahoo, google, and a few others, tend to just hang or not return anything? Does anyone have any good suggestions for any particular site? I'm trying on this webpage here so you can check to see if there is anything wrong and why it would be doing that? Thanks.
  18. If this is the case, you may want to look into templating engines or a template class that would provide these functions. However these can be quite bulky and slow your script down. If you are feeling adventurous you can code your own. To start you off, you may want something like this : function ReplacePelems($tcontent, $static_data) { foreach ($static_data as $prefix => $new_data) { $rowbegin = "<p name='" . $prefix . "'>"; $row_b_len = strlen($rowbegin); $startrow = strpos($tcontent, $rowbegin); $rowend = "</p name='" . $prefix . "'>"; $row_e_len = strlen($rowend); $endrow = strpos($tcontent, $rowend) + $row_e_len; $rowlen = $endrow - $startrow; $row = substr($tcontent, $startrow, $rowlen); $tcontent = str_replace($row, $new_data, $tcontent); unset($rows); } return $tcontent; } I just edited a function I had lying around and havn't tested it for u, but should put u in the right direction. Have a play around. If you are feeling adventurous you can replace the p with a preg_replace clause for elements (you should be able to find on the net) and change the $rowend with the result. I put the name="" bit in , as I didn't know how complex your pages are. $tcontent should be a getcontent result of the file you want to cahnge, and $static_data should be an array of the bits you want to change. keys should be what is specified in name="" and values should be what you want in between the elements. Good luck
  19. Oh, OK. I had a look, and I couldn't find the setting in IE6.1? Do you know where it is? Thanks.
  20. You need to use regular expressions, I find these quite complicated, but there are a number of good sites out there with some that u can use. The function you would need is preg_replace() / preg_match(). Try googleing regular expressions and then look up those functions in the manual. Good Luck.
  21. Is it possible, to get rid of the title of your page, the page numbers from the top of the page and the address and date from the bottom of the page when printing with css?
  22. Sorry, I should have mentioned I'm using MsSQL, which doesn't like backticks. The notice that is being displayed is : PHP Warning: mssql_result() [function.mssql-result]: Bad row offset (0) in D:\Inetpub\wwwroot\testing\classes\mri_central.php on line 348 When I comment out the E_USER_NOTICE And it displays my error when its not, which displays something like : PHP Notice: SELECT name FROM client WHERE clientId = 'NOR0000' Failed in D:\Inetpub\wwwroot\testing\classes\mri_central.php on line 348 If I copy and paste that into a query window, it returns the expected result, as it does normally.
  23. It's really annoying as I want to print the results of a page, but without having the notices flag up. Why does it keep displaying them, even though it returns the data correctly?
  24. Ok, no you are correct. This function is also used to determine whether $_SESSION['item_buy'] exists. So it would be better to use : //If product already exists, update the row. if (isset($_SESSION['item_buy']) && array_key_exists($modelId, $_SESSION['item_buy'])) { $price = number_format($price, 2, '.', ''); $session_qty = $_SESSION['item_buy'][$modelId][1] + $qty; $prod_net = number_format($qty * $price, 2, '.', ''); $prod_vat = number_format($prod_net * VAT, 2, '.', ''); $prod_gross = number_format($prod_net + $prod_vat, 2, '.', ''); $_SESSION['item_buy'][$modelId] = array($price, $session_qty, $prod_net, $prod_vat, $prod_gross); } else { $_SESSION['item_buy'][$modelId] = array($price, $qty, $prod_net, $prod_vat, $prod_gross); } Correct? Is there a better way to write this function?
  25. The notice is that the second argument must be an array, but it is not possible for $_SESSION['item_buy'] to be anything but an array. If I print_r it, it also shows as an array. [edit] I am not that bothered, but just wanted to know if I was using it correctly.
×
×
  • 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.