Jump to content

PHP SQL Problem


stacson

Recommended Posts

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!  :confused:

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.