misunderstanding browser vs server scripting?
<p>I would like to clarify how browser scripting (such as javascript/jquery) differs from server side scripting (such as PHP) and how they are allowed to interact with each other. </p>

<p>If I have php code inside of my html code, javascript definitly can not change any of that script since its not really there. The server first reads through the php code and then sends its output (as well as any normal html code in the file) over to the web browser, so the web browser never sees all your php code. On the flip side, php can't see the DOM because its not yet on the browser yet, and therefore be dynamic in the way javascript is. The way you make them interact is with ajax...</p>

<p>My question is: I have jquery ajax call which calls a php file to create a table and the table data has a  link in it. Is there any reason why when I create the table from this php file that I can't now access it through another jquery/javascript call?
This is my code:</p>

<pre><code> $(document).ready(function()
   {
        $("#build_table, .Course_Name, .Start_Date, .Book_Title, .Book_Author, .Book_Isbn").click(function()
        {
            var whichButton = $(this).attr("class");
            console.log("Whichbotton = " + whichButton);
            var prog = $("#program option:selected").text();
            var sch = $("#school option:selected").text();
            var trm = $("#term option:selected").text();
            var ext = $("#extension option:selected").text();
            if(prog == "" || sch == "" || trm == "")
            {
                alert("Please enter a selection for each field");
            }
            else
            {
                $.get("build_table.php", {program: prog, school: sch, term: trm, extension: ext, button: whichButton},
                function(table)
                {   console.log("Entered table function");
                    $("#input_table").replaceWith("&lt;div id='input_table'&gt;" + table + "&lt;/div&gt;");
                });
            }   
        });
   });
</code></pre>

<p>and my php file snippet:</p>

<pre><code>$program = $_GET["program"];
$school = $_GET["school"];
$term = $_GET["term"];
$extension = $_GET["extension"];
$button = $_GET["button"];

$con = mysql_connect("127.0.0.1","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

$term = str_replace(" ", "", $term); 
$sql = "SELECT * FROM tbl_name WHERE Dep1= '" . $program . "' AND Dep2= '" . $school . "' AND Dep3 = '" . $term . "'";
if($button == "build_table")
{
//add nothing  
}
else
{   echo $button;
$button = str_replace("_", " ", $button);
$sql = $sql . "ORDER BY `" . $button . "` DESC";
}   
mysql_select_db("csv_db", $con);

$result = mysql_query($sql)  or die(mysql_error());
echo $sql;
$num_rows = mysql_num_rows($result);
echo "&lt;br&gt;Number of Rows: " . $num_rows; 
echo "&lt;table id='booklist'&gt;&lt;tr&gt;
                         &lt;th&gt;Edit&lt;/th&gt;
                         &lt;th class='coursename'&gt;&lt;a href='#' class='Course_Name'&gt;Course Name&lt;/a&gt;&lt;/th&gt;
                         &lt;th class='startdate'&gt;&lt;a href='#'&gt;Start Date&lt;/a&gt;&lt;/th&gt;
                         &lt;th class='booktitle'&gt;&lt;a href='#'&gt;Book Title&lt;/&gt;&lt;/th&gt;
                         &lt;th class='bookauthor'&gt;&lt;a href='#'&gt;Book Author&lt;/a&gt;&lt;/th&gt;
                         &lt;th class='bookisbn'&gt;&lt;a href='#' class='Course Name'&gt;Book ISBN&lt;/a&gt;&lt;/th&gt;
                     &lt;/tr&gt;";

        while($row = mysql_fetch_array($result))
        { 
            echo    "&lt;tr&gt;
                        &lt;td&gt;&lt;input type='checkbox'&gt;&lt;/input&gt;&lt;/td&gt;
                        &lt;td class='coursename'&gt;" . $row['Course Name'] . "&lt;/td&gt;
                        &lt;td class='startdate'&gt;" . $row['Start Date'] . "&lt;/td&gt;
                        &lt;td class='booktitle'&gt;" . $row['Book Title']. "&lt;/td&gt;
                        &lt;td class='author'&gt;" . $row['Book Author']. "&lt;/td&gt;
                        &lt;td class='isbn'&gt;&lt;input class='ISBN_number' type='text' value='' size='13' maxlength='13'&gt;&lt;/input&gt;&lt;/td&gt; 
                  &lt;/tr&gt;";                   
        }               
echo "&lt;/table&gt;";

mysql_close($con);
</code></pre>

<p>I'm trying to make it that when I click on the header (of the table) Course Name it will sort the Course Name column (and yes there is a space in it... the backticks take care of it.) It doesn't work. On the other hand, when I tried putting in a simple html  into my normal html code</p>

<pre><code>&lt;a href="#" class="Course_Name" value="Course Name Sort"&gt;Course Name Sort&lt;/a&gt;
</code></pre>

<p>it now worked as I expected. Am I missing a concept or am I just making a simple error?</p>
