We help IT Professionals succeed at work.
Get Started

I need to learn how use php form to generate name/value pairs I can bring into Flash

Aadar
Aadar asked
on
365 Views
Last Modified: 2013-12-13
I have a PHP dynamic form that I need to generate name/value pairs from that Flash CS3 can bring in and use. Four of the values are user selected from dynamic menus and the fifth value is from a field in the record isolated by the users four choices.

I believe If the name/value pairs are generated I can bring them into the Flash portion of the page. I would prefer not to change pages to accomplish this, but instead gather the users input, create variables and load them into Flash.

Appreciate any help with this, PHP is new to me and I'm using WA tools to do most of it. The external interaction with Flash is new. I've just not needed to use it in the Flash that I have developed in the past.
<?php require_once('Connections/rbtSongs.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 
mysql_select_db($database_rbtSongs, $rbtSongs);
$query_rsInstrument = "SELECT DISTINCT instrumentID, instrument FROM rocksongs";
$rsInstrument = mysql_query($query_rsInstrument, $rbtSongs) or die(mysql_error());
$row_rsInstrument = mysql_fetch_assoc($rsInstrument);
$totalRows_rsInstrument = mysql_num_rows($rsInstrument);
 
mysql_select_db($database_rbtSongs, $rbtSongs);
$query_rsDifficulty = "SELECT DISTINCT difficultyID, difficulty FROM rocksongs";
$rsDifficulty = mysql_query($query_rsDifficulty, $rbtSongs) or die(mysql_error());
$row_rsDifficulty = mysql_fetch_assoc($rsDifficulty);
$totalRows_rsDifficulty = mysql_num_rows($rsDifficulty);
 
mysql_select_db($database_rbtSongs, $rbtSongs);
$query_rsSongTitle = "SELECT DISTINCT songTitleID, songTitle FROM rocksongs";
$rsSongTitle = mysql_query($query_rsSongTitle, $rbtSongs) or die(mysql_error());
$row_rsSongTitle = mysql_fetch_assoc($rsSongTitle);
$totalRows_rsSongTitle = mysql_num_rows($rsSongTitle);
 
mysql_select_db($database_rbtSongs, $rbtSongs);
$query_rsSongSection = "SELECT DISTINCT songTitleID, songTitle, songSection, songXML FROM rocksongs";
$rsSongSection = mysql_query($query_rsSongSection, $rbtSongs) or die(mysql_error());
$row_rsSongSection = mysql_fetch_assoc($rsSongSection);
$totalRows_rsSongSection = mysql_num_rows($rsSongSection);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php
if ($row_rsSongSection)     {
  echo "<SC" . "RIPT>\n";
  echo "var WAJA = new Array();\n";
 
  $oldmainid = 0;
  $newmainid = $row_rsSongSection["songTitleID"];
  if ($oldmainid == $newmainid)    {
    $oldmainid = "";
  }
  $n = 0;
  while ($row_rsSongSection)     {
    if ($oldmainid != $newmainid)     {
      echo "WAJA[".$n."] = new Array();\n";
      echo "WAJA[".$n."][0] = '".WA_DD_Replace($newmainid)."';\n";
      $m = 1;
    }
 
    echo "WAJA[".$n."][".$m."] = new Array();\n";
    echo "WAJA[".$n."][".$m."][0] = "."'".WA_DD_Replace($row_rsSongSection["songSection"])."'".";\n";
    echo "WAJA[".$n."][".$m."][1] = "."'".WA_DD_Replace($row_rsSongSection["songSection"])."'".";\n";
 
    $m++;
    if ($oldmainid == 0)      {
      $oldmainid = $newmainid;
    }
    $oldmainid = $newmainid;
    $row_rsSongSection = mysql_fetch_assoc($rsSongSection);
    if ($row_rsSongSection)     {
      $newmainid = $row_rsSongSection["songTitleID"];
    }
    if ($oldmainid != $newmainid)     {
      $n++;
    }
  }
 
  echo "var rsSongSection_WAJA = WAJA;\n";
  echo "WAJA = null;\n";
  echo "</SC" . "RIPT>\n";
}
function WA_DD_Replace($startStr)  {
  $startStr = str_replace("'", "|WA|", $startStr);
  $startStr = str_replace("\\", "\\\\", $startStr);
  $startStr = preg_replace("/[\r\n]{1,}/", " ", $startStr);
  return $startStr;
}
?>
<!-- InstanceBegin template="/Templates/subscriberSite.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Tablature</title>
<link href="p7ap/p7ap_06.css" rel="stylesheet" type="text/css" media="all" />
<link href="p7dejavu/p7dj02.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="p7ap/p7APscripts.js"></script>
<!--[if lte IE 6]>
<style type="text/css">
body {text-align: center;}
#logo, #tagline, #footer, #leftcolumn, #midcolumn, #rightcolumn {text-align: left;}
#wrapper, #footer, .menulist a {height: 1%;}
</style>
<![endif]-->
<script src="scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<style type="text/css">
<!--
.style1 {
	color: #000000
}
.style2 {
	font-size: xx-large;
	font-weight: bold;
}
.style3 {
	font-size: 2em
}
-->
</style>
<!-- InstanceBeginEditable name="Head" -->
<script type="text/javascript">
<!--
function WA_ClientSideReplace(theval,findvar,repvar)     {
  var retval = "";
  while (theval.indexOf(findvar) >= 0)    {
    retval += theval.substring(0,theval.indexOf(findvar));
    retval += repvar;
    theval = theval.substring(theval.indexOf(findvar) + String(findvar).length);
  }
  retval += theval;
  if (retval == "" && theval.indexOf(findvar) < 0)    {
    retval = theval;
  }
  return retval;
}
 
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
 
function WA_UnloadList(thelist,leavevals,bottomnum)    {
  while (thelist.options.length > leavevals+bottomnum)     {
    if (thelist.options[leavevals])     {
      thelist.options[leavevals] = null;
    }
  }
  return leavevals;
}
 
function WA_FilterAndPopulateSubList(thearray,sourceselect,targetselect,leaveval,bottomleave,usesource,delimiter)     {
  if (bottomleave > 0)     {
    leaveArray = new Array(bottomleave);
    if (targetselect.options.length >= bottomleave)     {
      for (var m=0; m<bottomleave; m++)     {
        leavetext = targetselect.options[(targetselect.options.length - bottomleave + m)].text;
        leavevalue  = targetselect.options[(targetselect.options.length - bottomleave + m)].value;
        leaveArray[m] = new Array(leavevalue,leavetext);
      }
    }
    else     {
      for (var m=0; m<bottomleave; m++)     {
        leavetext = "";
        leavevalue  = "";
        leaveArray[m] = new Array(leavevalue,leavetext);
      }
    }
  }  
  startid = WA_UnloadList(targetselect,leaveval,0);
  mainids = new Array();
  if (usesource)    maintext = new Array();
  for (var j=0; j<sourceselect.options.length; j++)     {
    if (sourceselect.options[j].selected)     {
      mainids[mainids.length] = sourceselect.options[j].value;
      if (usesource)     maintext[maintext.length] = sourceselect.options[j].text + delimiter;
    }
  }
  for (var i=0; i<thearray.length; i++)     {
    goodid = false;
    for (var h=0; h<mainids.length; h++)     {
      if (thearray[i][0] == mainids[h])     {
        goodid = true;
        break;
      }
    }
    if (goodid)     {
      theBox = targetselect;
      theLength = parseInt(theBox.options.length);
      theServices = thearray[i].length + startid;
      var l=1;
      for (var k=startid; k<theServices; k++)     {
        if (l == thearray[i].length)     break;
        theBox.options[k] = new Option();
        theBox.options[k].value = thearray[i][l][0];
        if (usesource)     theBox.options[k].text = maintext[h] + WA_ClientSideReplace(thearray[i][l][1],"|WA|","'");
        else               theBox.options[k].text = WA_ClientSideReplace(thearray[i][l][1],"|WA|","'");
        l++;
      }
      startid = k;
    }
  }
  if (bottomleave > 0)     {
    for (var n=0; n<leaveArray.length; n++)     {
      targetselect.options[startid+n] = new Option();
      targetselect.options[startid+n].value = leaveArray[n][0];
      targetselect.options[startid+n].text  = leaveArray[n][1];
    }
  }
  for (var l=0; l < targetselect.options.length; l++)    {
    targetselect.options[l].selected = false;
  }
  if (targetselect.options.length > 0)     {
    targetselect.options[0].selected = true;
  }
}
//-->
</script>
<!-- InstanceEndEditable -->
</head>
<body>
<div id="logo">
  <h1><a href="index.php"><img src="p7dejavu/img/dj_logo.jpg" alt="" width="280" height="36" border="0" /></a></h1>
  <div id="tagline">Tablature for Rhythm Gaming ...</div>
</div>
<div id="wrapper2">
  <div id="layoutcrown2">&nbsp;</div>
  <div id="midcolumn2">
    <div class="content"> <!-- InstanceBeginEditable name="MidColumn" -->
	<!-- InstanceEndEditable --></div>
  </div>
  <div id="rightcolumn">
    <div id="p7ABW1" class="p7AB">
      <div class="p7ABtrig">
        <h3><a href="javascript:;" class="style1" id="p7ABt1_1">&nbsp;&nbsp;Song Selection</a></h3>
      </div>
      <div id="p7ABw1_1">
        <div id="p7ABc1_1" class="p7ABcontent"><!-- InstanceBeginEditable name="leftNavTop" -->
          <form action="results.php" method="get" name="songSelectionForm">
            <table width="100%" border="0" cellspacing="2" cellpadding="2">
              <tr>
                <td><h1 class="menulist">Column for Display</h1>
                  <select name="columnSelection" class="menulist" id="columnSelection">
                    <option value="0">Choose Column</option>
                    <option value="1">Column One</option>
                    <option value="2">Column Two</option>
                    <option value="3">Column Three</option>
                  </select>
                </td>
              </tr>
              <tr>
                <td><h1 class="menulist">Select Instrument</h1>
                  <select name="instrumentSelection" class="menulist" id="instrumentSelection">
                    <option value="0">Choose Instrument</option>
                    <?php
do {  
?>
                    <option value="<?php echo $row_rsInstrument['instrumentID']?>"><?php echo $row_rsInstrument['instrument']?></option>
                    <?php
} while ($row_rsInstrument = mysql_fetch_assoc($rsInstrument));
  $rows = mysql_num_rows($rsInstrument);
  if($rows > 0) {
      mysql_data_seek($rsInstrument, 0);
	  $row_rsInstrument = mysql_fetch_assoc($rsInstrument);
  }
?>
                  </select>
                </td>
              </tr>
              <tr>
                <td><h1 class="menulist">Select Difficulty</h1>
                  <select name="difficultySelection" class="menulist" id="difficultySelection">
                    <option value="0">Choose Difficulty</option>
                    <?php
do {  
?>
                    <option value="<?php echo $row_rsDifficulty['difficultyID']?>"><?php echo $row_rsDifficulty['difficulty']?></option>
                    <?php
} while ($row_rsDifficulty = mysql_fetch_assoc($rsDifficulty));
  $rows = mysql_num_rows($rsDifficulty);
  if($rows > 0) {
      mysql_data_seek($rsDifficulty, 0);
	  $row_rsDifficulty = mysql_fetch_assoc($rsDifficulty);
  }
?>
                  </select>
                </td>
              </tr>
              <tr>
                <td><h1 class="menulist">Select Song Title</h1>
                  <select name="songTitleSelection" class="menulist" id="songTitleSelection" onchange="WA_FilterAndPopulateSubList(rsSongSection_WAJA,MM_findObj('songTitleSelection'),MM_findObj('songSectionSelection'),0,0,false,': ')">
                    <option value="0">Choose Song Title</option>
                    <?php
do {  
?>
                    <option value="<?php echo $row_rsSongTitle['songTitleID']?>"><?php echo $row_rsSongTitle['songTitle']?></option>
                    <?php
} while ($row_rsSongTitle = mysql_fetch_assoc($rsSongTitle));
  $rows = mysql_num_rows($rsSongTitle);
  if($rows > 0) {
      mysql_data_seek($rsSongTitle, 0);
	  $row_rsSongTitle = mysql_fetch_assoc($rsSongTitle);
  }
?>
                  </select>
                </td>
              </tr>
              <tr>
                <td><h1 class="menulist">Select Song Section</h1>
                  <select name="songSectionSelection" class="menulist" id="songSectionSelection">
                    <option value="0">Choose Song Section</option>
                  </select>
                </td>
              </tr>
              <tr>
                <td><div align="center">
                    <input type="submit" name="displayButton" id="displayButton" value="Display" />
                  </div></td>
              </tr>
            </table>
            <table cellpadding="2" cellspacing="0" border="0">
              <tr>
                <td align="center"><input type="hidden" name="WADbSearch1" value="submit" /></td>
              </tr>
            </table>
          </form>
          <!-- InstanceEndEditable --> </div>
      </div>
      <div class="p7ABtrig">
        <h3><a href="javascript:;" class="style1" id="p7ABt1_3">&nbsp;&nbsp;Rock Your Score . . .</a></h3>
      </div>
      <div id="p7ABw1_3">
        <div id="p7ABc1_3" class="p7ABcontent">
          <?php include('includes/leftNavContent.inc.php'); ?>
        </div>
      </div>
      <script type="text/javascript">
<!--
P7_opAB(1,1,1,1,0,1);
//-->
      </script>
    </div>
  </div>
  <div id="layoutbottom2">&nbsp;</div>
</div>
<div id="footerbox">
  <div id="footer">
    <p>&copy; 2008 Rock Your Score</p>
  </div>
</div>
</body>
<!-- InstanceEnd -->
</html>
<?php
mysql_free_result($rsInstrument);
 
mysql_free_result($rsDifficulty);
 
mysql_free_result($rsSongTitle);
 
mysql_free_result($rsSongSection);
?>

Open in new window

Comment
Watch Question
LAMP Developer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE