Jump to content

gwydionwaters

Members
  • Posts

    51
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

gwydionwaters's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. got it, using joins i had to be more specific with the columns MATCH (items.Title,items.Desc) AGAINST and in mysql 5.0 (not 5.1 like i have been reading tutorials for) there is no need for the AGAINST ('term' IN NATURAL LANGUAGE MODE) as opposed to AGAINST ('term') thanks for helping me figure it out
  2. ok, i got this which would be refering to this here i have tried it with caps and also i have tried searching the whole title. no luck there. i even tried matching only against title and using the full exact title of an entry, also no luck
  3. do i just add mysql_error(); i get this error on the page after a search attempt is there a better way to search a small (under 1000 entries) table? i only want to search two fields in the table. and i want to send a term or string (depending on user that is) and have it return all entires that contain the term or string in either field1 or field2 or both
  4. try this <?php "SELECT name FROM tblsections INNER JOIN tblsubsections ON tblsubsections.sectionid=tblsections.sectionid WHERE tblsubsections.subsectionid = '12'" where the '12' at the end is the value you are basing your search on, can be a variable too
  5. to get the genre name instead of the id <?php $result = $connector->query('SELECT Artists.Artist,Artists.Bio,Genres.Name FROM Artists INNER JOIN Genres ON Artists.Genres=Genres.Id WHERE ID = '.$HTTP_GET_VARS['id']); you can also do it like <?php $result = $connector->query('SELECT Artist,Bio,Name FROM Artists INNER JOIN Genres ON Artists.Genres=Genres.Id WHERE ID = '.$HTTP_GET_VARS['id']); i just like to use the table.field format for ease of reading. oh and because of the name used in the genres table you will have to echo Name instead of Genre
  6. thank you so much! works great now. at first it didn't and i couldn't figure out why, turns out that my if statements insert into author which was INSERT INTO author.Author, author.EMail VALUES ('$Author','$EMail'); for some reason wasn't working so i changed it to INSERT INTO author VALUES ('$Author','$EMail',''); which now works. again thanks for your help.
  7. ok, i'm with you that far now. i'm trying to work it out but i get confused without the actual database to try. i'll let you know if i figure it out, i might just recreate your tables on my server in the end
  8. now i find this strange, if in the case of the author already existing this works flawlessly but if the author is new there is an error as: also it has the same error if i use row 0 the code is this <? include("dbase.incl.php"); $Title=$_POST['Title']; $Author=$_POST['Author']; $EMail=$_POST['EMail']; $Type_id=$_POST['Type']; $Func_id=$_POST['Func']; $Cost_id=$_POST['Cost']; $Rating_id=$_POST['Rate']; $Description=$_POST['Description']; mysql_connect($hostname,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query1 = "SELECT author.Author, author.Author_id FROM author WHERE Author='$Author'"; $result1=mysql_query($query1); $num=mysql_num_rows($result1); // ** the error line is below ** $Author_id=mysql_result($result1,1,'Author_id'); if ($num =(0)) { $query2 = "INSERT INTO author.Author, author.EMail VALUES ('$Author', '$EMail')"; mysql_query($query2); $query3 = "SELECT author.Author_id FROM author WHERE Author = '$Author'"; $result2=mysql_query($query3); $Author_id=mysql_result($result2,1,'Author_id'); } $query4 = "INSERT INTO items VALUES ('','$Title','$Cost_id','$Type_id','$Func_id','$Rating_id','$Author_id','$Description')"; mysql_query($query4); mysql_close(); ?> i also had it so that it was like this <? include("dbase.incl.php"); $Title=$_POST['Title']; $Author=$_POST['Author']; $EMail=$_POST['EMail']; $Type_id=$_POST['Type']; $Func_id=$_POST['Func']; $Cost_id=$_POST['Cost']; $Rating_id=$_POST['Rate']; $Description=$_POST['Description']; mysql_connect($hostname,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query1 = "SELECT author.Author, author.Author_id FROM author WHERE Author='$Author'"; $result1=mysql_query($query1); $num=mysql_num_rows($result1); if ($num =(0)) { $query2 = "INSERT INTO author.Author, author.EMail VALUES ('$Author', '$EMail')"; mysql_query($query2); $query3 = "SELECT author.Author_id FROM author WHERE Author = '$Author'"; $result2=mysql_query($query3); $Author_id=mysql_result($result2,1,'Author_id'); } else { $Author_id=mysql_result($result1,1,'Author_id'); // ** This was where it was ** } $query4 = "INSERT INTO items VALUES ('','$Title','$Cost_id','$Type_id','$Func_id','$Rating_id','$Author_id','$Description')"; mysql_query($query4); mysql_close(); ?> sorry it may be messy, but like i said it works as long as the author already exists in author(table)
  9. one select being a select input type in an html form. i don't know if this should go in a java forum or not.. anyway the title says it all, what i want to do is instead of having <select name="option1"><option value="$var1"></option></select> i want to be able to send $var1 and $var2 as option1 in a way that i can use both as their own variable in the script they are sent to. maybe if i were to send it as "$var1,$var2" as $bundle and then somehow separate the two into their own variables on the other side? i am not sure how to do this, or what to google to learn for that matter
  10. so i have started another approach as a second option i have indexed (table)items on title and desc and now am trying this to get the key term in the select as text $Key=$_POST['Key']; $Key=trim($Key); //remove whitespace off ends include("dbase.incl.php"); mysql_connect($hostname,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "SELECT items.Title, items.Desc, author.Author, type.Type, func.Func, cost.Cost, rate.Rate FROM items INNER JOIN author ON items.Author_id = author.Author_id INNER JOIN type ON items.Type_id = type.Type_id INNER JOIN func ON items.Func_id = func.Func_id INNER JOIN cost ON items.Cost_id = cost.Cost_id INNER JOIN rate ON items.Rate_id = rate.Rate_id WHERE MATCH (Title,Desc) AGAINST ('"; $Key2 = $Key; //i want to use $Key as is later on $key2 .= "' IN BOOLEAN MODE)"; $query .= $Key2; $result=mysql_query($query); $num=mysql_num_rows($result); mysql_close(); but it say's my query is not a valid result resource my query would be SELECT items.Title, items.Desc, author.Author, type.Type, func.Func, cost.Cost, rate.Rate FROM items INNER JOIN author ON items.Author_id = author.Author_id INNER JOIN type ON items.Type_id = type.Type_id INNER JOIN func ON items.Func_id = func.Func_id INNER JOIN cost ON items.Cost_id = cost.Cost_id INNER JOIN rate ON items.Rate_id = rate.Rate_id WHERE MATCH (Title,Desc) AGAINST ('term' IN BOOLEAN MODE) is this an incorrect syntax?
  11. hmmm, i was re-reading your original post and i was becoming confused. i see in the table user_prefs_for_alloys(which i assume is a table containing information for each user?) there is the same alloy_id_no as in the new_alloys_added_by_users. if my assumption is correct i was wondering why a user is being associated with one alloy instead of just associating a user with every alloy of theirs in the new_alloys_added_by_users table, which may be creating a problem when trying to associate them
  12. that's wierd, my table is items, i skipped the s due to lazzines. my full query is as such SELECT items.Title, items.Desc, author.Author, type.Type, func.Func, cost.Cost, rate.Rate FROM items INNER JOIN author ON items.Author_id = author.Author_id INNER JOIN type ON items.Type_id = type.Type_id INNER JOIN func ON items.Func_id = func.Func_id INNER JOIN cost ON items.Cost_id = cost.Cost_id INNER JOIN rate ON items.Rate_id = rate.Rate_id WHERE items.Title LIKE '%$Key%' OR items.Desc LIKE '%$Key%' which like i said works fine with only the 'WHERE items.Title = '$Key'" but not with any sort of wildcard, nor will it return any results if i try "WHERE items.Title = '$Key' OR items.Desc = '$Key'"
  13. so i am trying to get a keyword search where the user can type in a word and have the select search two columns and return results from either/both columns. i have tried SELECT * FROM blah WHERE items.Title LIKE '%$Key%' OR items.Desc LIKE '%$Key%' also i have tried just where item.title = '$key' which works, but i want to be able to use a boolean type search. so you can search for car and get: car parts my new car etc ..
  14. what happens if you try this SELECT * FROM new_alloys_added_by_users JOIN user_prefs_for_alloys ON user_prefs_for_alloys.alloy_ID_No = new_alloys_added_by_users.alloy_ID_No INNER JOIN ratings_for_alloy_scores ON ratings_for_alloy_scores.alloy_ID_No = new_alloys_added_by_users.alloy_ID_No WHERE user_prefs_for_alloys.id = 1 AND ratings_for_alloy_scores.id_of_user_who_provided_this_rating = 1 it is what i would use
×
×
  • 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.