Darkmatter5 Posted April 28, 2009 Share Posted April 28, 2009 Here are my tables game_systems gs_idgame_idsystem_id 10146 102414 18845 games game_idtitledescrurl_wikipedia 4Fallout 3Blah blah blahnone genres genre_idgenre 5Role-Playing systems system_idabbreviation 5PS3 6360 14PC Now here's my query SELECT gs.gs_id, g.title, g.descr, ge.genre, g.url_wikipedia, gs.system_id, s.abbreviation FROM games AS g Inner Join game_systems AS gs ON gs.game_id=g.game_id Inner Join systems AS s ON s.system_id=gs.system_id Inner Join game_genres AS gg ON gg.game_id=g.game_id Inner Join genres AS ge ON gg.genre_id=ge.genre_id WHERE gs.game_id='4' ORDER BY s.abbreviation ASC If I run this query I get the following output. 101 Fallout 3 Blah blah blah none 6 360 102 Fallout 3 Blah blah blah none 14 PC 188 Fallout 3 Blah blah blah none 5 PS3 Now when I run this code through PHP $que_t="SELECT gs.gs_id, g.title, g.descr, ge.genre, g.url_wikipedia, gs.system_id, s.abbreviation FROM games AS g Inner Join game_systems AS gs ON gs.game_id=g.game_id Inner Join systems AS s ON s.system_id=gs.system_id Inner Join game_genres AS gg ON gg.game_id=g.game_id Inner Join genres AS ge ON gg.genre_id=ge.genre_id WHERE gs.game_id='4' ORDER BY s.abbreviation ASC"; $res_t=mysql_query($que_t) or die(mysql_error()); if(mysql_num_rows($res_t)<=0) { $othersys="<i> no system(s)</i>"; } else { while($systems=mysql_fetch_array($res_t)) { $othersys.="<a href='title.php?type=games&s=$systems[system_id]&g=all&c=all&i=4'>$systems[abbreviation]</a> "; } } echo "$othersys"; I get the following output to the page <a href='title.php?type=games&s=14&g=all&c=all&i=4'>PC</a> <a href='title.php?type=games&s=5&g=all&c=all&i=4'>PS3</a> It should be <a href='title.php?type=games&s=6&g=all&c=all&i=4'>360</a> <a href='title.php?type=games&s=14&g=all&c=all&i=4'>PC</a> <a href='title.php?type=games&s=5&g=all&c=all&i=4'>PS3</a> Where'd 360 go?? Quote Link to comment https://forums.phpfreaks.com/topic/156016-help-with-a-query/ Share on other sites More sharing options...
fenway Posted April 28, 2009 Share Posted April 28, 2009 If you're saying that the query works from phpmyadmin but not your php script, then this has nothing to do with the db. Quote Link to comment https://forums.phpfreaks.com/topic/156016-help-with-a-query/#findComment-821338 Share on other sites More sharing options...
Darkmatter5 Posted April 28, 2009 Author Share Posted April 28, 2009 Then is is possible for me to push this post to the PHP forum instead of having to recreate it? Quote Link to comment https://forums.phpfreaks.com/topic/156016-help-with-a-query/#findComment-821343 Share on other sites More sharing options...
redarrow Posted April 28, 2009 Share Posted April 28, 2009 is the 360 number in the database then? Quote Link to comment https://forums.phpfreaks.com/topic/156016-help-with-a-query/#findComment-821362 Share on other sites More sharing options...
Darkmatter5 Posted April 28, 2009 Author Share Posted April 28, 2009 Yes, if you look at the top of my post it shows the tables with the records. Quote Link to comment https://forums.phpfreaks.com/topic/156016-help-with-a-query/#findComment-821366 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.