Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. Whoops - neil's right there. No need for an alias. Excuse the brain fart.
  2. Arrays in all (sensible) programming languages index from 0. You've only selected one column from the table, so it's at index 0 not 1. You'd probably find it easier to give that field an alias an use that however: $qry1="select distinct (coder) AS coder from daily_reports where week_no=$wkno"; $exeQ1=mysql_query($qry1) or die ("Q1 :: Error ::: ".mysql_error()); while($row=mysql_fetch_assoc($exeQ1) ){ echo $row['coder'].'<br />; } ?>
  3. If you're looking to do this without having the page re-load, you'll need to look into AJAX. There's an FAQ about this very thing here There's two posts - the first showing how do it without a database, the second with. If you don't care about the page reload, you just need to have the form submit to itself - you can then grab the information for the second drop-down and fill it in.
  4. But the goal isn't to test the SQL per se, it's to test the switch.
  5. Indeed, but the OP also stated: "My results so far in page three are I can identify the truck from page one by $truckid =$_POST method", which leads me to believe that they have indeed successfully re-posted the data - in which case i'm not sure what's happening incorrectly. However, i do agree that sessions would probably be a better way to go. You might like to check out this tutorial, Graham: http://www.phpfreaks.com/tutorial/sessions-and-cookies-adding-state-to-a-stateless-protocol
  6. To test? Makes perfect sense to me. Edit: almost there SEVIZ, but you'll have to test the empty case separately and add quotes around those strings. E.g. if(!empty($_POST["recip"])){ switch ($_POST["recip"]) { case 'sl': echo "select `num` from sprint WHERE `dept` = 'sups AND leads'"; break; case 'north': echo "select `num` from sprint WHERE `loc` = 'north'"; break; case 'south': echo "select `num` from sprint WHERE `loc` = 'south'"; break; default: echo "select `num` from sprint WHERE `all` = 'all'"; } }else{ //empty }
  7. You've put single quotes around your field name. Therefore, it's treated as a string. Lexicographically, 'date' must be less than any number, therefore, it's deleting all the rows since it's true for all rows.
  8. It's more a matter of personal taste, but yes - if you're just checking the value of a variable against multiple cases, switch is usually nicer.
  9. Sure. Have my amazing money-spinning idea. Why wouldn't i want you to have it? In all seriousness, if anyone has a good idea, they'll be keeping it to themselves.
  10. If you want this to happen without a page reload, you should take a look into AJAX. You might like to check out this FAQ/Tutotrial : http://www.phpfreaks.com/forums/index.php/topic,155984.0.html The first post gives an example without a database, the second with.
  11. So am i. I've no idea what you're problem is. You never told us.
  12. I'm a little lost slightly on what the problem actually is - what's not happening that's supposed to be happening? I've a feeling we might need to see more code.
  13. Well if the queries are actually very similar, it might not be necessary. Are you just searching different tables? If so, just set the value of the options to be the name of the table you wish to query - you can then just insert the value of the drop-down into your query (after escaping it, of course)
  14. Indeed - if you are using sessions in order to implement a login then users will be logged out when they close their browser anyway. It you're concerned about security, you could also ensure that the user's not been inactive for more than x minutes. You might like to check out this tutorial on cookies and sessions if you're not too comfortable with them: http://www.phpfreaks.com/tutorial/sessions-and-cookies-adding-state-to-a-stateless-protocol
  15. Check example 2 of the manual page. It'll show you how to do it. The manual really should be your first port of call for things like this.
  16. Rumour has it that actually describing your post is quite helpful in receiving potential solutions. And please don't bump unnecessarily. If you ever find yourself actually needing to bump a topic, chances are you need to give more information.
  17. Don't double post. I'm pretty sure that after 434 posts you're capable of finding the correct place for your thread. I've already had to move the other one.
  18. Is there any better way to done this? ??? Well what exactly are you trying to achieve?
  19. Like I said though, in the above case the brackets aren't actually necessary - I would still use them, however.
  20. Stryves: Assuming the "Do This" code is the same, they're logically equivalent. However, the first is obviously nicer as it means you don't have to repeat that code. The if statement your first presented is indeed valid - the && operator has a higher precedence than the || operator, so is evaluated first. See this manual page for more on precedence. All that said, i personally would prefer to add the extra brackets as it makes it easier to read and you or other people are less likely to mistake the purpose of the if statement. E.g.: if( ($x=='1' && $y=='1') || ($x=='2' && $y=='5') )
  21. Using the value of HTTP_REFERER to show different content isn't a great idea. It can be spoofed to get around your checks - indeed using any information which came from the user can be altered. But worse, is doing this means potentially legitimate users will suffer - some firewalls prevent the referer from being send and browsers can be configured not to send it.
  22. Alright, i think im probably going to stick with the commenting in the header files. Hopefully my lecturer'll able to find them
  23. So for some reason we we're never introduced to the concept of using multiple files and using make in our c programming module. I've no idea why. I'm sure i can work out the details with the header files and how to produce a makefile, but i was wondering about best practices regarding commenting. I usually like to place a comment along with most functions to describe it's purpose and give a parameter list and return value. However, i'm wondering whether or not most people would expect to find this information in the header files or the source files? Seems kind-of logical to place it along with the function prototype in the header file, but then i also figure that it has it's merits being put alongside the actual code of the function -- i guess people are far more likely to be reading source files than header files. Any thoughts?
  24. Umm...i suppose you could parse the page and find out where you're going to be redirected to and go their yourself. However, if the site is employing something to stop you doing that manually (e.g. recording a timestamp), it wouldn't work anyway.
  25. If i follow correctly, you just need to retrieve the variable from the URL using the $_GET superglobal. See here for example. Once you've got that number, you obviously need to load the correct content be it from the a database or by including different files.
×
×
  • 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.