Jump to content

happs

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

happs's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi. Yes, it should really be an AND - but this returns nothing so I am obviously doing something wrong SELECT item FROM item2attr_adv WHERE valSelect = 31 AND valSelect = 44 Returns 0 records.
  2. Hi People I have a table (see attachment) that has an item ID and a valSelect ID. I need to create a query that returns the item ID only if two of the valSelect columns match a passed value. I have tried: SELECT item FROM item2attr_adv WHERE valSelect = 31 OR valSelect = 44 But this returns the item even if just ONE valSelect matches. See the two highlighted item rows in the attachment - they hav a valSelect of 31 and 44 so I want this item ID returning. [attachment deleted by admin]
  3. Hi People. Right - I'm having a NIGHTMARE trying to work this out. I have a table that has, let's say a property letting type and property building type with an id that points to another table that has further details about the specific property... [pre] property id type 1 holiday (id = 1) 1 house (id = 4) 2 residential (id = 2) 2 flat / apartment (id = 3) [/pre] I need a query string that gets the Property ID only ONCE if the type matches, for instance, holiday and house. Any help would be great!!
  4. Hi, Thanks for that. Yeh it works now... just trying to work out WHY it works. Heh. - Alex
  5. Hey people I'm slowly but surely getting there .. This script is to check an input field that asks for a name of a pool league. It is meant to check for leagues with the same name, and if one is found, show the name of the duplicate league and then give the option to edit it - instead of creating a duplicate. If one of the same name isn't found then check_duplicate returns FALSE and the new league is added. HOWEVER ... It does't work. Hehe. I get the following errors .. Notice: Undefined variable: row_leagues in C:\Websites\maccpoolleague\leagues_ex.php on line 159 Notice: Undefined variable: row_leagues in C:\Websites\maccpoolleague\leagues_ex.php on line 159 Notice: Undefined variable: row_leagues in C:\Websites\maccpoolleague\leagues_ex.php on line 160 Here's the function: function check_duplicate(){ $query_leagues = mysql_query("SELECT id AS id, name AS name, format AS format FROM leagues"); // open connection. if (mysql_num_rows($query_leagues) > 0) { // only run the check if there is one or more leagues. while ($row_leagues = mysql_fetch_array($query_leagues)) { // start streaming the leagues. if (strtoupper(trim($_POST['name'])) == $row_leagues['name'] && $_POST['format'] == $row_leagues['format']) { // look for a match of league names and format. return ($row_leagues); // if found, finish function and return array - $row_leagues ['name'], ['id'] and ['format'] } } return false; // if, after streaming the leagues, none are found that match the input then return false. } else { return false; // ditto for no leagues already in database, as it doesn't need to check. } } And here's the function call: if (check_duplicate()) { // is it TRUE, uh OH ! YES! Better make them aware! echo '<b>Error:</b> There is already a league with that name and format: <br />' . $row_leagues['name'] . ' (' . $row_leagues['format'] . ')'; echo ' [ <a href="' . $_SERVER['PHP_SELF'] . '?action=edit&league_id=' . $row_leagues['id'] . '">EDIT THIS LEAGUE</a> ]'; } else { // It's FALSE then so add it. add_league(); }; Thanks for your help in advance - Alex
  6. Hey That's much better -- neater in a way. Thanks - Alex
  7. Hi Is using <meta http-equiv="refresh" content="0"; url="<? echo $_SERVER['PHPSELF']; ?>"> really the best way to refresh the page? For instance, I have a form that once submitted calls a PHP function to carry out the required task, and then goes back to showing what has been submitted by refreshing the page. The above script works fine, but is using a META really the best way of doing this ? Thanks for your ideas in advance. - Alex
  8. Hey peeps Hoping you can help.. function add_league () { $name = strtoupper(trim(addslashes($_POST['name']))); mysql_query("INSERT INTO leagues (name, format, division) VALUES ('{$name}', '{$_POST['format']}', 'A')"); echo 'League Added: ' . $name . '(' . $_POST['format'] . ')'; echo ' [ <a href="' . $_SERVER['PHP_SELF'] . '?action=edit&league_id=' . $row_leagues['id'] . '">EDIT THIS LEAGUE</a> ]'; } As you can see, an entry has just been made into the database, but the following echo requires that entrie's ID. What is the best way of getting the LAST entry into the database ? Or even better, get THAT entrie's ID. Thank you very much for your help in advance. - Alex
  9. Just to clarify .. I have a table with a date column in the format of YYYY-MM-DD for a database of events. Each event has a date and I want the site I am working on to get the NEXT event according to today's date. Would this code work for this also ? Thanks in advance - Alex [!--quoteo(post=315172:date=Nov 5 2005, 08:49 PM:name=bigfatwallet)--][div class=\'quotetop\']QUOTE(bigfatwallet @ Nov 5 2005, 08:49 PM) 315172[/snapback][/div][div class=\'quotemain\'][!--quotec--] Thank you so much. I can't believe I didnt think of that myself, I was trying min and max and all sorts of sutff! lol Once again 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.