Search script query doesn't work

From: Date: Sat, 08 Jul 2000 17:10:09 +0000
Subject: Search script query doesn't work
Groups: php.general 
Request: Send a blank email to php-general+get-5548@lists.php.net to get a copy of this message
The main problem is that the query doesn't work, I think it has something to do with the variables values from the form: A minor problem is when I bring up the page it already performs a search without having to click on submit. There are two tables in one database $query = "SELECT * FROM albums, songs WHERE '$category' = '$testband' AND songs.albumid = albums.albumid"; The full script is listed below: Here is the form part: <form> <TR><TD>Searcher: <input type=text name='usertypes'><br></TD> <TD>Search via <select name="category" size="1"> <option value="albums.Artist"selected>Artist</option> </option><option value="albums.AlbumID">AlbumID </option><option value="albums.Album">Album </option><option value="albums.Genre">Genre </option><option value="songs.songname">Song Name </option><option value="albums.picture_name">picturename </option><option value="albums.description>description </option><option value="albums.year>year </option></select> </TR> </TABLE> <TD><input type=submit></TD> </form> </TR> Here is the php/mysql db stuff: mysql_connect("blah.blah.com", "test", "mypassword"); //@mysql_select_db( "$dbName") or die( "Unable to select database"); /* Query */ $query = "SELECT * FROM albums, songs WHERE '$category' = '$testband' AND songs.albumid = albums.albumid"; $result = mysql_db_query("musicdb", $query); if ($result) { echo "Found these entries in the database:<ul>"; while ($r = mysql_fetch_array($result)) { $AlbumID = $r["AlbumID"]; $Album = $r["Album"]; $Artist = $r["Artist"]; $Genre = $r["Genre"]; $picture_name = $r["picture_name"]; $description = $r["description"]; $year = $r["year"]; $songname = $r["songname"]; ?> <!-- Output --> <TR><TD> <? echo "$AlbumID"; ?></TD> <TD> <? echo "$Album"; ?></TD> <TD> <? echo "$Artist"; ?></TD> <TD> <? echo "$Genre"; ?></TD> <TD><? echo "$picture_name"; ?></TD> <TD><? echo "<img src=/covers/$picture_name ALT='Cover Image' width=71 height=71>"; ?> </TD> <TD><? echo "$year"; ?></TD> <TD><? echo "$songname"; ?></TD> <? } echo "</ul>"; ?> </TABLE>

« previous php.general (#5548) next »