Jump to content

grissom

Members
  • Posts

    166
  • Joined

  • Last visited

Everything posted by grissom

  1. Thanks Pikachu. I'll do exactly that. Thanks once again.
  2. Try this : (watch the inverted commas carefully) $q = "SELECT * FROM student WHERE sno ='$_GET[sno]' "; or if that is still tying you up in knots, break it down $my_sno = $_GET['sno']; // this time with inverted commas around the 'sno' $q = "SELECT * FROM student WHERE sno = '$my_sno' ";
  3. Hi all I am running XAMPP on my laptop and working with files not in the localhost directory. For functions like fopen, there is no problem, I specify a path starting from the localhost directory to wherever I want to work and that's fine. For some reason though, it is NOT working with IMG SRC. I get my PHP to generate the following line of code : <IMG SRC = "http://localhost/../../../wherever/android.jpg"> (which in this case points to C:\wherever\android.jpg) However the browser misses the middle bit of the URL out and interprets it just as localhost/wherever/android.jpg - which clearly doesn't exist ! Likewise, if I try typing the address straight into the address bar, the '../../../' bit of it immediately vanishes. I've tried formatting the URL in a variety of ways, none of them seem to work, where am I going wrong ? Many thanks !
  4. No matter, solved it ! select staff, sum(if(day ='MON', sales,0)), sum(if(day ='TUE', sales,0)), sum(if(day ='WED', sales,0)) from aliceandbob group by staff
  5. Hi, I am looking to output a MYSQL table in a certain way. Here's an example, imagine I have a sales database like this Staff Day Place Sales ==== === ==== ===== Alice MON Town 5 Alice MON City 6 Alice TUE Town 7 Bob TUE Town 3 Bob TUE City 2 And I'd like to turn it into something like this : Total Sales by Day MON TUE Alice 11 7 Bob 0 5 For sure I can do it in PHP using a few "loops" but is there a way to do it in a single MYSQL statement ?
  6. TA DAH !!!! THANKS mikosiko !!
  7. I know this sounds obvious, but it's easy to make a mistake (as the hedgehog said getting off the toilet brush) - just check that when you set up the database on the server, you typed in the user name and password correctly and didn't inadvertently put in any typos. In those password boxes where the characters come up as asterisks, its easy to put a typo in and not realise. Also check that the server has not "helpfully" appended any suffixes automatically to the username (one of mine does !). Sorry if this sounds obvious, but I've done it myself ....
  8. Hi folks, here's my problem Imaging I have one table which shows department names and the payroll number for the manager and deputy for each department table : departments -------------------------- dept manager deputy ------- ------------- --------- Sales 0123 9876 Marketing 2222 4567 Accounts 5656 7890 I also have an employees table as follows : table : employees ----------------------- payroll firstname surname -------- ------------ ----------- 0123 Fred Foo 2222 Bert Bar 9876 James Bond 4567 Dick Barton I would like to do a JOIN query between departments and employees to produce : Department Mgr first Name mgr surname Deputy first name Deputy surname --------------- ---------------- ---------------- ---------------------- -------------------- Sales Fred Foo James Bond Marketing Bert Bar Dick Barton There is a (slightly long winded) way to do it in PHP by looping through the database, but to do it in one MYSQL statement would mean JOINing the employees table TWICE (something MYSQL does not appear to like) Is there any really snazzy, slick way of producing the bottom view from the top two tables in one single MYSQL statement ? Cheers and MANY THANKS !
×
×
  • 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.