Jump to content

Switch0r

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Everything posted by Switch0r

  1. I do have 1 final question (I promise I'll stop annoying everyone after this!) Will that query work with more than 2 columns? So when using the DISTINCT x.name portion, could that be x1.x2.x3 etc?
  2. Scratch that last one, I've just checked it, and it works...I should really try things before I post
  3. That works like a charm! Is there any way to still select first1, last1, first2, & last2 all as separate items though? If not could I use the concatenated name to then make another search? ie. SELECT * WHERE CONCAT(first1, ' ', last1) = $fullname OR CONCAT(first2, ' ', last2) = $fullname;
  4. I'm running MySQL 5.0.41, so that shouldn't be a problem should it? With the query in my prev post running i get this response: H Mike Hodges Charles Herman-Wurmfeld Brian Helgeland Stephen Herek Amy Heckerling John Hamburg Guy Hamilton Albert Hughes Jared Hess Walter Hill Curtis Hanson Renny Harlin Allen Hughes (It's a list of film directors in case you were wondering ) The list should be sorted by the last name of all items going a-z, but it's not What I was thinking, other than changing the query to do it for me, was either making a temp table and populating it with the results, then querying that table to get a properly sorted list, or populating an array with all the stuff and sorting that somehow...
  5. Thanks for that! I've gone with the UNION option (so I can keep the values of first1/last1 etc separate), although now I can't get the sorting I want to work. My query is now this: (SELECT last1, first1 FROM table WHERE last1 LIKE '$operator' ORDER BY last1) UNION (SELECT last2, first2 FROM table WHERE last2 LIKE '$operator' ORDER BY last2) This gets all the data I need for my list, although I want to sort all the items together, not just have last1 a-z then last2 a-z, I want (last1 & 2) a-z. I'm thinking of some kind of temporary table situation (which I read about optimizing in the mysql docs, but not actually how to go about it...). Any thoughts?
  6. Hey peeps, I just want to know if something is possible, particularly as I don't really know how to implement what I want... Right, so I've got a table that i want to get pairs of unique records from 4 separate columns (its for 2 sets of peoples first & last names), named first1, last1, first2, last2. I want to be able to select unique variations of first & last for both, and then get a unique set of records covering both people. I hope this makes sense I'll give an example... First/Last 1 we have: Jeff Beck, Jeff Buckley, Jeff Daniels First/Last 2 we have: James Dean, Jeff Daniels, Paul Daniels From the query I want 1 set of records to be: Jeff Beck, Jeff Buckley, Jeff Daniels, Paul Daniels, James Dean Bearing in mind that the first/last names are in different columns of the table. Any thoughts? Some kind of JOIN maybe (I've never used one before...)?
  7. right, I figured it out...I feel sheepish I was trying to use LIKE multiple times which wasnt working, as i wasnt telling it what it should be like each time. ie where title like '1%' or '2%' etc... - wrong! where title like '1%' or title like '2%' etc... - works like a charm
  8. Im trying to retrieve a set of records by their starting character, some of which begin with numbers. I have no problem getting the lettered items out, just the numbers. What i want to have is a list that gives everything starting 0-9, then letters from a-z. Firstly is there any query that will search for an array of LIKE values? id. LIKE '0-9%'? Or am I going to have to run a while loop on the query for each number separately? (Which I also have no problem doing, it just seems rather an inelegant way of doing things... Thanks for any help
  9. Is there something in it that would need turning on/off?
  10. well I'm afraid this doesn't work either, still just shows the nopic image
  11. Cheers Stuie, I'd already seen that and it makes as much sense to me a second time as it did the first I had tried it with the local file path, and that doesn't work either
  12. I'm having some trouble with file_exists... I want to find out whether an image file exists for a given url, and display it if it does, or display a different image if it doesn't. What i've got so far is this: function picture($picture) { // Create url for file path $filepath = "http://localhost/images/" . $picture; if(file_exists($filepath)) { ?> <img src="images/<?php echo $picture; ?>" alt=""> <?php } else { ?> <img src="images/nopic.jpg" alt=""> <?php } } And it doesn't work, it always returns FALSE and the nopic.jpg is displayed, even tho I know for a fact that the file does exist. Running on Apache 2.0.559 & php 5.1.5 on winxp (if this makes any difference??) I've tried all manner of other functions I can find inf the php manual, but they don't work, and file_exists is the one that fits the purpose...
  13. why don't you just open the code in notepad, and find/replace any instances of the tags you want lowercase with the match case option on? Unless the code is not saved locally/user inputted online (?)
  14. Well it depends on what your query is really. For example, if you query any rows where the username in the db matches the user inputted username, and then check the number or rows returned, if its greater than 0 then you know you've got it already and you can give an error to the user, and make them pick again. [code] if(mysql_num_rows($result) > 0) { -------> Username Exists, give error } else { -------> No already in db, proceed with script } [/code] So no need to get all the data from the db, and no while loops either.
  15. Would it not be simpler to have all the tables you need in the same db, with a prefix on the table name? eg. info1_blah, info2_blah, info3_blah Then you can still keep the same header file you already have, and make the drop down box select the table name instead?
  16. try this: http://vertrigo.sourceforge.net/ no hassle to install/setup, plus its an all in one install package, me loves it :)
  17. right, well I've checked what i've already got, and it turns out that you are all more than correct, and i already had what i wanted anyway. i feel sheepish, i'll baa all the way home now :)
  18. doesn't that just select a distinct last name and a 'whatever' first name though? i want a distinct first/last combo
  19. Hey peeps, was wondering if anyone can help me. I'm trying to get a list of all distinct field pairs from a table i have (the table is listing artists in a cd collection if that makes any difference) and i have the first and second names that i want to get distinct values of. essentially i want to select a distinct pair of first and last, rather than just distinct last, as there may be crossover of the 2 names. eg: jeff buckley tim buckley i want to select a distinct pair rather than just the last name any ideas?
  20. thats another thing, what exactly is em anyway?
  21. all sorted! i hadnt thought of the margins on my css :) whats the default on those anyway?
  22. not easily, its all on my local server with db gubbins goin on...and ive only got my free isp webspace atm :( is there anything i can put in my css file to control the margin/line height or something? http://joncoope.homecall.co.uk/problem.css this is what i got so far update: http://joncoope.homecall.co.uk/test.html any ideas?
  23. here is an example to show what i mean http://www.joncoope.homecall.co.uk/doctype_off.jpg http://www.joncoope.homecall.co.uk/doctype_on.jpg the edge of the image is where the edge of the table cell is. no changes to the page/css made, just adding the doctype
  24. When putting the HTML 4.01 Transitional doctype on my page: [code]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">[/code] all my paragraph tags get an equal height (in font size) gap above and below all elements??? it only causes a problem in firefox and opera, makes no difference either way in IE. taking the doctype out of the page fixes everything in firefox and opera tho...anyone got any ideas? Cheers :)
  25. right, well...ive sorted it :) added the $_POST array vars for the comparison, but changed the check so it checks if its "on" or not, as i had previously thought that checkboxes gave either 1 (checked) or 0 (blank), which apparently is untrue as it comes up as: on (checked) or empty var (blank) thanks for the help tho peeps [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /]
×
×
  • 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.