Jump to content

Switch0r

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

About Switch0r

  • Birthday 04/29/1983

Contact Methods

  • MSN
    jonny_coope@hotmail.com

Profile Information

  • Gender
    Male
  • Location
    Manchester, UK

Switch0r's Achievements

Newbie

Newbie (1/5)

0

Reputation

  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?
×
×
  • 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.