title: sending php array to javascript function onclick
body: <p>Little problem about sending PHP array to javascript function, i did homework looked everywhere and i know its not reliable to do this, but at this moment i do not know any other way , so try to just advice me how to finish it anyway.</p>
  
  <p>I got php code executing first , idea is on page load i get some data from MySQL , i filled php array with IDs from that select statement.</p>
  
  <pre><code>&lt;?php
  include('config.php');
  $TicketExist = "select BetSlipID,probatip1.betslips.MatchID as GameID, 
  TipID,tim1.Name AS HomeTeam ,tim2.Name AS AwayTeam, UserID 
  from probatip1.betslips
  inner join probatip1.matches matches on probatip1.betslips.MatchID = matches.MatchID
  inner join probatip1.teams tim1 on matches.HomeTeamID = tim1.TeamID
  inner join probatip1.teams tim2 on matches.AwayTeamID = tim2.TeamID
  where UserID = 1";
  
  $TicketResult = mysql_query($TicketExist);
  $TicketNum = mysql_numrows($TicketResult);
  
  mysql_close();
  
  if($TicketNum != 0)
  {
  $s=0;
  while($s &lt; $TicketNum)
  {       
  
      $GameID = mysql_result($TicketResult,$s,"GameID");
      $TipID = mysql_result($TicketResult,$s,"TipID");    
      $ArrayIDs[$s] = $GameID;
      echo "&lt;script&gt;window.onload=GetInfo($GameID,$TipID); &lt;/script&gt;";
      $s++;
  }
  } 
  ?&gt;
  </code></pre>
  
  <p>So i got it everything i want filled and wrote on my page , idea now is on user click , to call javascript to take this '$ArrayIDs' and execute code from script</p>
  
  <p>Here is code im calling script </p>
  
  <pre><code>&lt;ul&gt;
  &lt;li 
  id="ConfirmButton" name="Insert" method="post" 
  onclick="GetAllIDs(&lt;?php $ArrayIDs ?&gt;)"&gt;&lt;a&gt;POTVRDI&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>And my script code</p>
  
  <pre><code>function GetAllIDs(Ticket) {
  $("td.ID").each(function () {
  
      var MatchID = $(this).attr('id');
      var lab = "Label";
  
      var Label = lab + MatchID;
  
      var Final = document.getElementById(Label);
  
      var TipID;
  
      if (Final.innerHTML == '1') {
          TipID = 1;
      }
      else if (Final.innerHTML == 'X') {
          TipID = 2;
      }
      else if (Final.innerHTML == '2') {
          TipID = 3;
      }
      else {
          return;
      }
  
  
      var request_type;
      var browser = navigator.appName;
  
  
      if (browser == "Microsoft Internet Explorer") {
          request_type = new ActiveXObject("Microsoft.XMLHTTP");
      }
      else {
          request_type = new XMLHttpRequest();
      }
  
      var http = request_type;
  
      var AlreadyPlayed = false;
  
      if (Ticket != null) {
          var TicketExists = Ticket;
          for (var i = 0; i &lt; TicketExists.length; i++) {
              if (TicketExists[i] == MatchID) {
                  AlreadyPlayed = true;
                  break;
              }
          }
      }
  
      if (http != null) {
  
          if (AlreadyPlayed == true) {
              http.open('get', 'update.php?MatchID=' + MatchID + 
              '&amp;TipID=' + TipID + '&amp;UserID=' + 1, true);
          }
          else {
              http.open('get', 'insert.php?MatchID=' + MatchID + 
              '&amp;TipID=' + TipID + '&amp;UserID=' + 1, true);
          }
          http.send(null);
      }
  });
  
  if (Ticket == null) {
      alert('Tiket je napravljen');
  }
  else {
      alert('Tiket je promenjen');
  }
  }
  </code></pre>
  
  <p>With this posted code when i am debugging code with firebug in mozzila i get that my 'Ticket' parameter that suppose to be '$ArrayIDs' is undefined.</p>
  
  <p>Reason why i want to make array and send it to javascript onclick event is to check if user already placed a bet on some game , if he did i want to send all data for update and if he did not yet placed bet on some game to send data for insert in database.
  So i need array and before anything just to check MatchID with all IDs in my array, so i know what to do.</p>
  
  <p>Thanks all in advance for helping out</p>