Jump to content

marmite

Members
  • Posts

    204
  • Joined

  • Last visited

    Never

Everything posted by marmite

  1. If I've got you correctly: use GET or POST & SESSION to track the dropdown item, e.g. If form has been posted, i.e. <? if ($_POST['themes']) { $_SESSION['theme']=POST['theme'] } ?> the form itself has e.g. <form action="/greetingscards.php" method="post" name = "themes" id="themes"> <table width="90%"> <tr width="100%">Theme</tr> <tr> <td width="50px"> <select name="theme" id="theme1"> <option value="all"<?php if($_SESSION['theme'] == "all") { echo ' selected="selected"'; } ?>>All</option> <option value="animal"<?php if($_SESSION['theme'] == "animal") { echo ' selected="selected"'; } ?>>Animal</option> <option value="floral"<?php if($_SESSION['theme'] == "floral") { echo ' selected="selected"'; } ?>>Floral</option> <option value="leisure"<?php if($_SESSION['theme'] == "leisure") { echo ' selected="selected"'; } ?>>Leisure</option> <option value="travel"<?php if($_SESSION['theme'] == "travel") { echo ' selected="selected"'; } ?>>Travel</option> </select> </td> <td><input type="submit" name="submit3" value="Find cards!" /></td> </tr> </table> </form> (all that extra PHP just keeps the selection selected between pages) Then your PHP code which sets the SQL simply has an IF stmt, e.g. if ($_SESSION['themes'] = 'animal') { $query="blah blah order by xyz asc"; } elseif ($_SESSION['themes']='floral') { $query="blah order by abc asc"; } Sorry I've written this off the top of my head but hope you get the basic idea. Basically put the dropdown selection into a session variable (assuming you want to keep it between pages, and don't forget the session_start() declaration at the top of each page), and then alter your SQL according to that variable value.
  2. This isn't my area of expertise, but I had a similar problem and discovered that it WAS sending the email, but my SPAM filters on my inbox were weeding out the emails. Worth a check.
  3. solved here: http://www.codingforums.com/showthread.php?p=568309&posted=1#post568309
  4. Thanks for this. I've done some googling and it seems that the user would have had to enable sms 2 email on their account. Is this right? Is there any other way of doing this so that nothing but the number is required from the user? e.g. what these guys do doesn't require knowledge of the phone service provider: http://www.cbfsms.com/
  5. Sorry if this is in the wrong bit. Does anyone know anything about sending SMS or MMS from my server (so, users could be texted that their order had been dispatched)? I don't know where to start looking... do I need something particular installed or will it work with my normal mail server? Thanks Emma
  6. Hello, May seem a silly question, but hey ho: do I need to worry about SQL injection/any form of attack on this page: http://www.cardsunlimited.com/contact.php which just sends a mailto ? I am assuming not. Also, I know this is cheeky but I haven't been able to sort this javascript problem for over a week, so if you're reading this and you know some JS, could you take a look (it's very basic and I'd be very grateful!)- http://www.phpfreaks.com/forums/index.php/topic,141303.0.html Emma
  7. Thanks - but every time I tried that, I had problems with the code actually completing. For example, in the below, the line alert("hello") does not execute. Any ideas why not? Many thanks Emma function verify() { var i=0; var notblank=0; var numrows=<?php echo $numrows3; ?>; for (i;i<=numrows;i=i+1) { var instance="qty_" + i; if (document.getElementById(instance).value !=0) { alert(document.getElementById(instance).value); notblank=1; } } alert("hello"); if (notblank!=1) { alert("Please enter a quantity to add to the cart") return(false) } return(true) }
  8. I'm a JS newbie, and still struggling on the same bit of code!! if (document.getElementById(instance) > 0) { This line isn't working. I've tried "!= null", "!=''" etc, nothing's working. So I think there are two possibles: 1) either "document.getElementById(instance)" is not correctly referring to the text inputs. 2) or something is wrong with my comparison operator (e.g. i shouldn't use !=null...) Can anyone tell me how to check the first thing, that it is referring correctly? Been working on this all week.. please help... Emma _______________________________________ Overrall purpose: I want a pop-up to alert the user that they haven't entered a value into the text inputs, when they click add to cart. (the alerts below are just for me to debug and this is in Test). Whole code: <script language="JavaScript" type="text/javascript"> <!-- function verify() { var i=0; var notblank=0; var numrows=<?php echo $numrows3; ?>; for (i;i<=numrows;i=i+1) { var instance="qty_" + i; if (document.getElementById(instance) > 0) { alert(document.getElementById(instance)); notblank=1; } } alert(notblank) if (notblank!=1) { alert("Please enter a quantity to add to the cart") return(false) } return(true) } //--> </script>
  9. Yep. I've done a few print_rs and narrowed down the problem. My SESSION['prevpage'] and SESSION['currpage'], which determine all the cart functions, are resetting from retailgreetingcards.php and bulkview.php respectively, to bulkview.php and notfound.php respectively (i.e. 404 error). This is happeniing BEFORE the code below is called... it's like some sort of weird refresh error, just for users who've come via a certain page... baffled if (!isset($_GET['deleteid'])) { if ($_SESSION['currpage']) { $_SESSION['prevpage']=$_SESSION['currpage']; $_SESSION['prevquery']=$_SESSION['currquery']; } $_SESSION['currpage']=$_SERVER['PHP_SELF']; $_SESSION['currquery']=$_SERVER['QUERY_STRING']; }
  10. I'm not clear what you're trying to do. Do you want to pick a few items from the database at RANDOM?
  11. This is a really odd one. I have one page, bulkview.php, which shows various products with a GET param, e.g. http://www.cardsunlimited.com/bulkview.php?id=pink_rose This bulkview page processes information differently depending whether the previous page (stored in $_SESSION['prevpage']) was greetingscards.php, retailgreetingcards.php, or partyinvitations.php. So, e.g. it only shows cellophane-wrapped cards to users who've come via retailgreetingcards. But the page won't add to cart for those who've come via retailgreetingcards !! It works on Test. It works for all other routes. It was working yesterday, or the day before. The problem seems to be that all SESSION variables are unsetting themselves when users click Add to Cart but why? why?? I don't know where to start on this one. Can anyone help? Emma
  12. OK, scrap that, removed the .value from "if (document.getElementById(instance)!= null) {" and now I get all the pop-ups. But still I am passing the if condition when I shouldn't be. function verify() { var i=0; var notblank=0; var numrows=<?php echo $numrows3; ?>; for (i;i<=numrows;i=i+1) { var instance="qty_" + i; if (document.getElementById(instance)!= null) { alert(document.getElementById(instance).value); notblank=1; } } alert(notblank); if (notblank==1) { alert("Please enter a quantity to add to the cart") return(false) } return(true) }
  13. Thanks for this.. still struggling... your code works great, but with the code below, four empty text inputs return four alerts with nothing in them (i.e. they are passing the if condition, which says if NOT null...). So they're null, but they're passing for not nulls. Confused! Moreover, sometimes alert(nonblank) and alert(please enter a quantity...) run and sometimes not. I find this very odd. Can you shed any light? Thanks Emma function verify() { var i=0; var notblank=0; var numrows=<?php echo $numrows3; ?>; for (i;i<=numrows;i=i+1) { var instance="qty_" + i; if (document.getElementById(instance).value != null) { alert(document.getElementById(instance).value); notblank=1; } } alert(notblank); if (notblank==1) { alert("Please enter a quantity to add to the cart") return(false) } return(true) }
  14. have you tried setting the code you want as innerhtml to a variable, and then using that? e.g. var newHTML = "<a href='/bulkview.php?id=champagne' title='greetings card'><img src='/images/homepage/1.jpg' width='100' height='100' border='0' alt='view greetings card' /></a>"; document.getElementById('area1').innerHTML = newHTML;
  15. Hi, complete JS newbie, and struggling! I have the following code, and all i need to do is pass the variable "i" correctly into it. Where code says qty_i, that is because elsewhere in the code there are a (dynamic) number of inputs, called: qty_1, qty_2 etc. So the line with the problem is: if (!(document.mycart.qty_+i == '')) { I want to check that at least one input ahs a value before user clicks add to cart. Grateful for any help! function verify() { alert ("hello"); var i=0; var notblank=0; var numrows=<?php print "'".$numrows3."'"; ?>; for (i;i<=numrows;i=i+1) { if (!(document.mycart.qty_+i == '')) { notblank=1; } } if (!(notblank==1)) { alert("Please enter a quantity to add to the cart") return(false) } else { return(true) } }
  16. THANKYOU The second one didn't seem to work (?) but when I selected with "as" it worked fine. That's a useful technique. Cheers
  17. When I print_r an array (which I've got from an SQL query), I get "Array ( [0] => 2 )" All I need to do is set a variable to "2" or whatever this Array produces. There will only ever be one result as it is returning a count(distinct) How do I do this??? I am going INSANE trying to figure this out. Please help!
  18. OK, so array_unique should work. But this code will not work: it returns 1 even when there are 2 different messages returned. Print_r returns "resource id 6", and echo returns 1. Grateful for help.... $count="SELECT packaging_message from `abc` where packaging_message in (SELECT card_message from xyz where card_image_id='$id2')"; $count1=mysql_query($count) or die ("Error in query " . mysql_error()); print_r($count1); echo count (array_unique($count1));
  19. Perhaps I confused matters by including that code. I am looking for a PHP version of "select distinct". Do you know of one?
  20. Hi, I need to structure a table differently depending whether the card is available only with one inside (e.g. blank) or whether it's available with two (e.g. blank & happy birthday). I have an SQL query returning the message, so I want to check whether there is more than one distinct value in an array. The array exists already (e.g. $row['message']). Does anyone know a suitable function for this? Like, count_distinct_results... (Originally I started off struggling with a separate SQL, which didn't seem to return the expected number: $query4="select count(card_msg) from xyz where image_id='$id2'"; $result4=mysql_query($query4) or die ("Error in query " . mysql_error()); $row4=mysql_fetch_assoc($result4); ) Thanks!
  21. oh my goodness! That is SO much easier than the javascript nightmare I went through. Thanks! I'll try that. Emma
  22. Hi, I want to generate my own sitemap, ideally using a VBA script in Excel. To do this, I really want to export all the filenames and property information for a particular folder (last modified etc) from Windows Explorer. Is this possible? Does anyone know how? Or does anyone have a VB script that touches upon this? I have never coded in VB in spite of its similarity to VBA. Thanks Emma
  23. I'm not certain what you're trying to select - a list of city names? I would guess that the problem is the d1.* Perhaps it's multiplying all d1 rows by number of db2.citynameinenglish Does that sound possible? Also, you refer to one db as d1 (as you've named it) and the other as db2. (as though you haven't named it). Maybe try d2. instead?
  24. what do you get when you just try "order by date_field asc" ? is the system not clever enough to work it out? what data type is the field defined as? is it a date type?
×
×
  • 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.