Jump to content

xiao

Members
  • Posts

    163
  • Joined

  • Last visited

    Never

Everything posted by xiao

  1. I have this query: $qry = mysql_query("SELECT p.products_id, p.products_model, p.products_price, pd.products_name FROM products p, products_description pd, products_to_categories pc WHERE p.products_id = pd.products_id AND pd.language_id = '".$instT."' GROUP BY pd.products_name ORDER BY p.products_price") or die(mysql_error()); But I need some "AND PC.categories_id = $variable" in it like this: foreach($instV400 as $voedingCat){ echo "AND pc.categories_id = '".$voedingCat."' "; } So it should look somewhat like this: $qry = mysql_query("SELECT p.products_id, p.products_model, p.products_price, pd.products_name FROM products p, products_description pd, products_to_categories pc WHERE p.products_id = pd.products_id AND pd.language_id = '".$instT."' " . foreach($instV400 as $voedingCat){ echo "AND pc.categories_id = '".$voedingCat."' "; } . "GROUP BY pd.products_name ORDER BY p.products_price") or die(mysql_error()); But I have no idea how to build a query like that :-\
  2. Fixed it. I was trying to use those variables inside functions ' Is there maybe a better way besides using 'global $...' everytime I need sth in a function? I don't really want to use session variables either since I already use like 30 of those.
  3. I currently use something like this: config.php <?php /** * @author Sander Quirynen * @copyright IPCS.be */ # Language //ID of... $instT = "1"; index.php ... require ("config.php"); ... But I get an error on my index.php saying Notice: Undefined variable: instT in C:\xampp\htdocs\pcconfig\index.php on line 128 I include the file on line 8...
  4. I have 2 arrays: $_SESSION['geheugenBussen'] = array("DDR2-533","DDR2-667","DDR2-800","DDR2-900","DDR2-1000","DDR2-1066","DDR2-1100 en hoger","DDR2-1333"); $_SESSION['geheugenBussenCat'] = array("417","423","424","425","428","427","429","1277"); Each value in $_SESSION['geheugenBussen'] corresponds to 1 value in $_SESSION['geheugenBussenCat'] (so DDR2-667 = 423) I want to create a select list like this: <select...> <?php echo "<option value=\"" . $_SESSION['geheugenBussen'] . "\">" . $_SESSION['geheugenBussenCat'] . "</option"; ?> </select> But I need to output them all. How do I do this? Or is there a better way to make my arrays?
  5. How is it less secure? And does it improve performance? The database information only changes 2 times a day, so that's not a big problem.
  6. What does it do? Print text like in ASP or just start the script? (just wondering)
  7. Do you have to send POST and SESSION variables to functions? Like: function something($postvar,$sessionvar){ echo $postvar . " " . $sessionvar; } Or can a function read those anyway, like this? function something(){ echo $_POST['var1'] . " " . $_SESSION['var2']; }
  8. What I need: All products with a model starting with 'DVD-FD' OR 'DVD-DH'. My code doesn't return stuff that starts with 'DVD-FD' (it does return the one with 'DVD-DH'). And it also return a product with 'MG....' $qryProcessor = mysql_query("SELECT p.products_id, p.products_model, p.products_price, pd.products_name FROM products p, products_description pd WHERE p.products_id = pd.products_id AND pd.language_id = 1 AND p.products_model LIKE 'DVD-DH%' OR p.products_model LIKE 'DVD-FD%' GROUP BY p.products_id ORDER BY p.products_price") or die(mysql_error()); I'm using osCommerce if it helps.
  9. I have a form with quite some drop down lists. Everytime a drop down changes, the form is submitted again. All other lists depend on previously selected options. Is it better to put query results in session variables or to redo the query everytime? And is it even possible to put them in session variables?
  10. got it working. I gave the <select> also an id="behuizing" and used this: var begin = behuizing.options[behuizing.selectedIndex].value.search(/>>>/);
  11. Yea, I read it. But I tried this: var begin = document.behuizing.selectedIndex.value.search(/>>>/); and it still says So it's still the same error.
  12. This works (the original script), but only when I remove the doctype... <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <meta name="author" content="joske"> <title>Untitled 1</title> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function changeImage() { mainimage.src = list.options[list.selectedIndex].value; } function prevImage() { if(list.selectedIndex == 0) { list.selectedIndex = list.options.length-1; } else { list.selectedIndex--; } changeImage(); } function nextImage() { if(list.selectedIndex == list.options.length-1) { list.selectedIndex = 0; } else { list.selectedIndex++; } changeImage(); } // End --> </script> </head> <BODY onLoad="javascript:changeImage()"> <center> <img name="mainimage" border="1" src="1.gif"> <br> <input type="button" value="Terug" onclick="javascript:prevImage()"> <select id="list" onchange="javascript:changeImage()"> <option value="1.gif">Eerste Image</option> <option value="2.gif">Tweede Image</option> <option value="3.gif">Derde Image</option> <option value="4.gif">Vierde Image</option> <option value="5.gif">Vijde Image</option> </select> <input type="button" value="Volgende" onclick="javascript:nextImage()"> </body> </html>
  13. But I need the search() thingy I tried this: var begin = document.behuizing.selectedIndex.value.search(/>>>/); But it still says
  14. I have something that looks like this: <html> <head> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function veranderAfbeelding() { var begin = document.behuizing.value.search(/>>>/); var einde = document.behuizing.value.search(/<<</); document.afbeelding.src = document.behuizing.options[document.behuizing.selectedIndex].value.substring(begin,einde); } function vorigeAfbeelding() { if(document.behuizing.selectedIndex != 0) { document.behuizing.selectedIndex--; } veranderAfbeelding(); } function volgendeAfbeelding() { if(document.behuizing.selectedIndex != document.behuizing.options.length-1) { document.behuizing.selectedIndex++; } veranderAfbeelding(); } // End --> </script> </head> <body onLoad="javascript:veranderAfbeelding()"> <form action="" method="POST"> <select name="behuizingprijs"> <option value="0">tot €50</option> <option value="50">€50 tot €75</option> <option value="75">€75 tot €100</option> <option value="100">€100 tot €150</option> <option value="150">> €150</option> </select> <img name="afbeelding" src="1.gif"> <input type="button" value="<" onclick="javascript:vorigeAfbeelding()"> <select name="behuizing" class="behuizing" onchange="javascript:veranderAfbeelding()"> <option value="10 - DVD-UNSG2 - 29.9900 - Under Siege 2 - Dark Territory - >>>dvd/under_siege2.gif<<<">Under Siege 2 - Dark Territory - 29.9900</option> </select> <input type="button" value=">" onclick="javascript:volgendeAfbeelding()"> And I get this error from FireBug: I get the same type of error when I click those buttons, so I'm probably doing the same thing wrong a couple of times.
  15. That looks a lot better indeed, but I need to get the categories_id from products_to_categories. Right now it gives this error: Unknown column 'p.categories_id' in 'where clause'
  16. This seems to work a little better: $result = mysql_query("SELECT p.products_id, p.products_model, p.products_price, p.products_image, pd.products_name, pc.categories_id FROM products p, products_description pd, products_to_categories pc WHERE pc.categories_id = 10 AND p.products_id = pd.products_id AND pd.language_id = 1 AND p.products_price <=50 GROUP BY pd.products_name ORDER BY p.products_price") or die(mysql_error()); But it appears to give products with any category_id
  17. I have this query: $result = mysql_query("SELECT p.products_id, p.products_model, p.products_price, p.products_image, pd.products_name, pc.categories_id FROM products p, products_description pd, products_to_categories pc WHERE pc.categories_id = 10 AND pd.language_id = 1 AND p.products_price <=50 ORDER BY p.products_price") or die(mysql_error()); What it should do: Get id, model, price, image and name for all products with category 10 that have a price <= 50 I'm using it in osCommerce so I had to include the language_id part to only get the english ones. But now with the above query I get product like 5 or 6 times (might be more), and I don't know how to fix that... I tried some GROUP BYs, but that seems to give incorrect rows.
  18. So if I understand it correct, this can be right? $result = mysql_query("SELECT products.products_id, products.products_model, products.products_price, products_description.products_name FROM products, products_description WHERE products.products_id = products_description.products_id AND products.products_model LIKE 'CEA%' OR products.products_model LIKE 'CEB%' OR products.products_model LIKE 'CDA%' OR products.products_model LIKE 'CDB%' OR products.products_model LIKE 'CJB%' OR products.products_model LIKE 'CGB%'") or die(mysql_error()); And the way you do it (much better imo ) it would be: $result = mysql_query("SELECT pproducts_id, p.products_model, p.products_price, pd.products_name FROM products p, products_description pd WHERE p.products_id = pd.products_id AND p.products_model LIKE 'CEA%' OR p.products_model LIKE 'CEB%' OR p.products_model LIKE 'CDA%' OR p.products_model LIKE 'CDB%' OR p.products_model LIKE 'CJB%' OR p.products_model LIKE 'CGB%'") or die(mysql_error());
  19. I found it while searching for wildcard. I just found this: http://www.htmlite.com/mysql011.php It says: So I guess multiple underscores will work
×
×
  • 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.