stacson Posted March 5, 2011 Share Posted March 5, 2011 Hi there, I have a map of America made in flash, where you click on a state and the page should display the SQL database information for that state in the HTML table - but instead all it shows is the first entry of the database regardless of which state you click and it doesn't display the 2 radio buttons. My code is as follows Flash Actionscript 3 (just showing one state) function waClick(event:MouseEvent):void { var waURL:URLRequest = new URLRequest("restaurants.php?state=Washington"); navigateToURL(waURL, "_self"); } wa_btn.addEventListener(MouseEvent.CLICK, waClick); PHP code <?php include("mvfconnect.php"); $theChoice = $_GET['state']; $query = "SELECT * FROM restaurants WHERE" .$theChoice; $result = @ mysql_query($query); if (!$result) { $message="Unfortunately we are having problems with this page, we promise to have it fixed as soon as possible"; die($message); } $num = mysql_num_fields($result); $i=0; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $show1=substr($row['state'],0,50)."..."; $show2=substr($row['city'],0,50)."..."; $show3=substr($row['rname'],0,50)."..."; $show4=substr($row['address'],0,50)."..."; $show5=substr($row['pnum'],0,50)."..."; $show6=substr($row['web'],0,50)."..."; $show7=substr($row['dishes'],0,50)."..."; $show8=substr($row['dish_details'],0,50)."..."; $show9=substr($row['challenges'],0,50)."..."; $show10=substr($row['challenge_details'],0,50)."..."; $show11=substr($row['youtube'],0,50)."..."; $show12=substr($row['images'],0,50)."..."; echo "<tr>". "<td>".$row['city']."</td>". "<td>".$row['rname']."</td>". "<td>".$row['address']."</td>". "<td>".$row['pnum']."</td>". "<td>".$row['web']."</td>". "<td>".$row['dishes']."</td>". "<td>".$row['challenges']."</td>". "<td id='state".$i."' style='display:none'>".$row['state']."</td>". "<td id='city".$i."' style='display:none'>".$row['city']."</td>". "<td id='rname".$i."' style='display:none'>".$row['rname']."</td>". "<td id='address".$i."' style='display:none'>".$row['address']."</td>". "<td id='pnum".$i."' style='display:none'>".$row['pnum']."</td>". "<td id='web".$i."' style='display:none'>".$row['web']."</td>". "<td id='dishes".$i."' style='display:none'>".$row['dishes']."</td>". "<td id='dish_details".$i."' style='display:none'>".$row['dish_details']."</td>". "<td id='challenges".$i."' style='display:none'>".$row['challenges']."</td>". "<td id='challenge_details".$i."' style='display:none'>".$row['challenge_details']."</td>". "<td id='youtube".$i."' style='display:none'>".$row['youtube']."</td>". "<td id='images".$i."' style='display:none'>".$row['images']."</td>". "<td><input type='radio' name='vid' id='vid".$i."' onclick='openVideo(".$i.")' /></td>". "<td><input type='radio' name='pic' id='pic".$i."' onclick='openImage(".$i.")' /></td>". "<td class='last'style='display:none'>".$show1." ".$show2." ".$show3." ".$show4." ".$show5." ".$show6." ".$show7." ".$show8." ".$show9." ".$show10."</td>". "</tr>"; $i++; } ?> I have used this code before and it has worked fine, can someone please help me out! Quote Link to comment https://forums.phpfreaks.com/topic/229653-php-sql-problem/ Share on other sites More sharing options...
Brandon_R Posted March 5, 2011 Share Posted March 5, 2011 It looks as though the state Washington is hard coded into the file. Make sure you are passing through the state when you click. Quote Link to comment https://forums.phpfreaks.com/topic/229653-php-sql-problem/#findComment-1183223 Share on other sites More sharing options...
stacson Posted March 5, 2011 Author Share Posted March 5, 2011 Hmm I thought I was, how would I go about doing that? Quote Link to comment https://forums.phpfreaks.com/topic/229653-php-sql-problem/#findComment-1183226 Share on other sites More sharing options...
sasa Posted March 5, 2011 Share Posted March 5, 2011 change your query to $query = "SELECT * FROM restaurants WHERE state=" .mysql_real_escape_string($theChoice); Quote Link to comment https://forums.phpfreaks.com/topic/229653-php-sql-problem/#findComment-1183239 Share on other sites More sharing options...
stacson Posted March 5, 2011 Author Share Posted March 5, 2011 Thanks for the reply but that didin't work. It just gives me a blank table. Quote Link to comment https://forums.phpfreaks.com/topic/229653-php-sql-problem/#findComment-1183242 Share on other sites More sharing options...
PFMaBiSmAd Posted March 5, 2011 Share Posted March 5, 2011 Your query needs single-quotes around the state = '...' data since it is a string. Quote Link to comment https://forums.phpfreaks.com/topic/229653-php-sql-problem/#findComment-1183271 Share on other sites More sharing options...
stacson Posted March 5, 2011 Author Share Posted March 5, 2011 Hey there, yep that was the problem. Thanks. The solution was - $query = "SELECT * FROM restaurants WHERE state='$theChoice'"; Quote Link to comment https://forums.phpfreaks.com/topic/229653-php-sql-problem/#findComment-1183275 Share on other sites More sharing options...
Brandon_R Posted March 5, 2011 Share Posted March 5, 2011 Sorry, did not see Flash Actionscript 3 (just showing one state) Silly me. Quote Link to comment https://forums.phpfreaks.com/topic/229653-php-sql-problem/#findComment-1183283 Share on other sites More sharing options...
stacson Posted March 5, 2011 Author Share Posted March 5, 2011 Hey thats not a problem. Thanks for trying to help me. Quote Link to comment https://forums.phpfreaks.com/topic/229653-php-sql-problem/#findComment-1183284 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.