title: Using javascript within php script
body: <p>I have some code here that I use to change or swap images when moused over. This is the javascript code:</p>
  
  <pre><code>&lt;script type="text/javascript" language="Javascript"&gt;
  
  var imgdir = "category_icons/";
  
  blank_icont = new Image;
  blank_icont.src= imgdir+"blank_text.png";
  vieworder_icon = new Image;
  vieworder_icon.src = imgdir+"vieworder.png";
  vieworder_icono = new Image;
  vieworder_icono.src= imgdir+"vieworder2.png";
  //vieworder_icont = new Image;
  //vieworder_icont.src= imgdir+"vieworder.png";
  
  function changeImages(name) { 
  document.images[name].src = eval(name + '_icono.src');
  document.images.icon_text.src  = eval(name + '_icont.src');
  }
  
  function changeImages2(name){ 
  document.images[name].src = eval(name + '_icon.src');
  document.images.icon_text.src  = eval('blank_icont.src');
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>Inside my PHP script I have this bit of code:</p>
  
  <pre><code>$dynamiclist = '&lt;table align="center" width="60%" border="0" cellspacing="5" cellpadding="8"&gt;
                          &lt;tr height="10"&gt;&lt;hr style="width: 60%;"&gt;&lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td width="30% valign="top" align="left"&gt;&lt;img style="border: #66cc33 5px solid;" src="./menupictures/'. $picturepath . '" height="140" width="140" border="1"/&gt;&lt;/td&gt;
                              &lt;td width="40%" valign="top" align="left"&gt; ' . $name . ' &lt;br /&gt; $' . $price . ' &lt;br /&gt;&lt;br /&gt;&lt;a href="moreinfo.php?id=' . $id .'"&gt;More Info&lt;/a&gt;&lt;/td&gt;
                              &lt;td width="30% valign="top" align="left"&gt;&lt;a onmouseover="changeImages("vieworder")" onmouseout="changeImages2("vieworder")" href="customize.php?id=' . $id .'"&gt;&lt;img id="vieworder" src="category_icons
                                                                          /vieworder.png" alt="" name="vieworder" border="0"&gt;&lt;/a&gt;&lt;/td&gt;
  </code></pre>
  
  <p>You'll notice where I try to use the functions <code>changeImages</code>. Is it not working because I can't use javascript this way? Or do I have my quotations incorrect? I've tried changing some things around by moving quotations, but nothing is working. </p>
  
  <p>HERE IS THE FULL CODE:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  
  &lt;script type="text/javascript" language="Javascript"&gt;
  
  var imgdir = "category_icons/";
  
  blank_icont = new Image;
  blank_icont.src= imgdir+"blank_text.png";
  vieworder_icon = new Image;
  vieworder_icon.src = imgdir+"vieworder.png";
  vieworder_icono = new Image;
  vieworder_icono.src= imgdir+"vieworder2.png";
  //vieworder_icont = new Image;
  //vieworder_icont.src= imgdir+"vieworder.png";
  
  function changeImages(name) { 
  document.images[name].src = eval(name + '_icono.src');
  document.images.icon_text.src  = eval(name + '_icont.src');
  }
  
  function changeImages2(name){ 
  document.images[name].src = eval(name + '_icon.src');
  document.images.icon_text.src  = eval('blank_icont.src');
      }
  &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;!-- This is where the table section starts --&gt;
  &lt;table&gt;&lt;tr height="50"&gt;&amp;nbsp;&lt;/tr&gt;&lt;/table&gt; 
  &lt;/body&gt;
  &lt;/html&gt;
  
  &lt;?php
  /* ----------------------------------- CONNECTING AND QUERYING THE DATABASE -----------------------*/
  
  require("database.php"); //connect to the database
  
  $start = (isset($_GET['start']) ? (int)$_GET['start'] : 0); //setting the get function for pagnation
  
  $result = mysqli_query($con,"SELECT * FROM menuitem WHERE type='kids'LIMIT $start, 3"); //mysql statement. first argument $starat specifies the offset of the first row to return, and the second specifies the maximum number of rows to return 
      if (!$result) {
          printf("Error: %s\n", mysqli_error($con));// Displays the error that mysql will generate if syntax is not correct.
          exit();
      }
  
  
  echo '&lt;table&gt;&lt;tr height="20"&gt;&lt;/tr&gt;&lt;/table&gt;
  
          &lt;table height="50" width="60%" align="center" border="0" cellpadding="0" cellspacing="0" align="center"&gt;
              &lt;tr&gt;
                  &lt;td width="300" align="left"&gt;&lt;font style="font-weight:bold;"&gt;Menu Items&lt;/font&gt;&lt;/td&gt;
                  &lt;td width="400" align="left"&gt;&lt;font style="font-weight:bold;"&gt;Menu Information&lt;/font&gt;&lt;/td&gt;
                  &lt;td width="300" align="left"&gt;&lt;font style="font-weight:bold;"&gt;Add to Order&lt;/font&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;';
  /* ----------------------------------- PULLING IN THE DATA -----------------------*/
  
  //DYNAMIC PHP PULLING IN THE DATA AND SPITTING OUT THE RESULTS
  while($row = mysqli_fetch_array($result))
  {
      $id = $row['id'];
      $description = $row['description'];
      $picturepath = $row['picturepath'];
      $name = $row['name'];
      $price = $row['price'];
  
      $dynamiclist = '&lt;table align="center" width="60%" border="0" cellspacing="5" cellpadding="8"&gt;
                          &lt;tr height="10"&gt;&lt;hr style="width: 60%;"&gt;&lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td width="30% valign="top" align="left"&gt;&lt;img style="border: #66cc33 5px solid;" src="./menupictures/'. $picturepath . '" height="140" width="140" border="1"/&gt;&lt;/td&gt;
                              &lt;td width="40%" valign="top" align="left"&gt; ' . $name . ' &lt;br /&gt; $' . $price . ' &lt;br /&gt;&lt;br /&gt;&lt;a href="moreinfo.php?id=' . $id .'"&gt;More Info&lt;/a&gt;&lt;/td&gt;
                              &lt;td width="30% valign="top" align="left"&gt;&lt;a onmouseover="changeImages(&amp;quot;vieworder&amp;quot;)" onmouseout="changeImages2(&amp;quot;vieworder&amp;quot;)" href="customize.php?id=' . $id .'"&gt;&lt;img id="vieworder" src="category_icons
                                                                          /vieworder.png" alt="" name="vieworder" border="0"&gt;&lt;/a&gt;&lt;/td&gt;
                          &lt;/tr&gt;
                      &lt;/table&gt;';
      echo $dynamiclist;
      }
  </code></pre>