I am new to Javascript/PHP, so have a few basic questions. I am trying to create a javascript array from php. All goes okay till I am reference collumn '0' or 'pid' from my sql table, but as soon as I try to access the next collumn 'Function' the javascript stops working. I have created a testcase with alert (same to be replaced by an array) Would really appreciate all your help.
<?php
$baseName . "jobs";
$tableName = $baseName . "dbTable";
# datbase info .done.
$con = mysql_connect("localhost",$userName,$password);
if (!$con){
echo('Could not connect: ' . mysql_error());
}
mysql_select_db($dbName, $con);
$result = mysql_query("SELECT * FROM " . $tableName);
$count = 0;
echo "<table border='1'>
<tr>
<th>ID</th>
<th>Function</th>
<th>Position</th>
<th>Location</th>
<th>Experience</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['pid'] . "</td>";
echo "<td>" . $row['Function'] . "</td>";
echo "<td>" . $row['Position'] . "</td>";
echo "<td>" . $row['City'] . ', ' . $row['State'] . "</td>";
echo "<td>" . $row['Experience'] . "</td>";
echo "</tr>";
?>
<script type="text/javascript">
alert(<?php echo $row['pid']?>); <!-- this works -->
**alert(<?php echo $row['Function']?>); <!-- this does not works -->**
</script>
<?php
$count++;
}
echo "</table>";
mysql_close($con);
?>