Variable not working in PHP
I am retrieving data from database using AJAX and PHP. In database one of the columns contains path of an image folder. I am saving the value of path in a PHP variable named as $folder. This can be seen in getuser.php code.<br /> I want this variable to be visible/available in one.php so that my images using this variable could be populated. How would i do this. I have tried including php as well but no use.

<br /><br />
**getuser.php**<br />
 

       <?php
    $q=$_GET["q"];
    
    $con = mysql_connect('localhost', 'san', '123');
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("holidayNet", $con);
    
    $sql="SELECT * FROM image WHERE id = '".$q."'";
    
    $result = mysql_query($sql);
    
    echo "<table border='1'>
    <tr>
    <th>Firstname</th>
    <th>Lastname</th>
    <th>Age</th>
    <th>Hometown</th>
    <th>Picture</th>
    </tr>";
    
    while($row = mysql_fetch_array($result))
      {
    	$folder = $row['FirstName'];
      echo "<tr>";
     echo "<td>" . $row['FirstName'] . "</td>";
      echo "<td>" . $row['LastName'] . "</td>";
      echo "<td>" . $row['Age'] . "</td>";
      echo "<td>" . $row['Hometown'] . "</td>";
      
    
      /*echo "<td>" . $row['Job'] . "</td>";*/
      echo "</tr>";
      }
    echo "</table>";
    
    mysql_close($con);
    
    
    ?> 

<br /><br />
**one.php**<br />

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <script type="text/javascript">
    function showUser(str)
    {
    if (str=="")
      {
      document.getElementById("txtHint").innerHTML="";
      return;
      }
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","getuser.php?q="+str,true);
    xmlhttp.send();
    }
    </script>
    </head>
    <body>
    
    <form>
    <select name="users" onchange="showUser(this.value)">
    <option value="">Select a person:</option>
    <option value="1">Sn Qb</option>
    <option value="2">Lois Griffin</option>
    <option value="3">Glenn Quagmire</option>
    <option value="4">Joseph Swanson</option>
    </select>
    </form>
    <br />
    <div id="txtHint"><b>Person info will be listed here.</b></div><br />
    
    <img src="<?php echo $folder;?>/pic1.jpg" />
    <img src="<?php echo $folder;?>/pic2.jpg" />
    <img src="<?php echo $folder;?>/pic3.jpg" />
    <img src="<?php echo $folder;?>/pic4.jpg" />
    
    
    </body>
    </html> 
Variable not working in PHP
===

I am retrieving data from database using AJAX and PHP. In database one of the columns contains path of an image folder. I am saving the value of path in a PHP variable named as $folder. This can be seen in getuser.php code.<br /> I want this variable to be visible/available in one.php so that my images using this variable could be populated. How would i do this. I have tried including php as well but no use.

<br /><br />
**getuser.php**<br />
 

       <?php
    $q=$_GET["q"];
    
    $con = mysql_connect('localhost', 'san', '123');
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("holidayNet", $con);
    
    $sql="SELECT * FROM image WHERE id = '".$q."'";
    
    $result = mysql_query($sql);
    
    echo "<table border='1'>
    <tr>
    <th>Firstname</th>
    <th>Lastname</th>
    <th>Age</th>
    <th>Hometown</th>
    <th>Picture</th>
    </tr>";
    
    while($row = mysql_fetch_array($result))
      {
    	$folder = $row['FirstName'];
      echo "<tr>";
     echo "<td>" . $row['FirstName'] . "</td>";
      echo "<td>" . $row['LastName'] . "</td>";
      echo "<td>" . $row['Age'] . "</td>";
      echo "<td>" . $row['Hometown'] . "</td>";
      
    
      /*echo "<td>" . $row['Job'] . "</td>";*/
      echo "</tr>";
      }
    echo "</table>";
    
    mysql_close($con);
    
    
    ?> 

<br /><br />
**one.php**<br />

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <script type="text/javascript">
    function showUser(str)
    {
    if (str=="")
      {
      document.getElementById("txtHint").innerHTML="";
      return;
      }
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","getuser.php?q="+str,true);
    xmlhttp.send();
    }
    </script>
    </head>
    <body>
    
    <form>
    <select name="users" onchange="showUser(this.value)">
    <option value="">Select a person:</option>
    <option value="1">Sn Qb</option>
    <option value="2">Lois Griffin</option>
    <option value="3">Glenn Quagmire</option>
    <option value="4">Joseph Swanson</option>
    </select>
    </form>
    <br />
    <div id="txtHint"><b>Person info will be listed here.</b></div><br />
    
    <img src="<?php echo $folder;?>/pic1.jpg" />
    <img src="<?php echo $folder;?>/pic2.jpg" />
    <img src="<?php echo $folder;?>/pic3.jpg" />
    <img src="<?php echo $folder;?>/pic4.jpg" />
    
    
    </body>
    </html> 