Javascript alert in php file doesn't display
Posted: Wed Jun 25, 2008 5:58 am
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
I'm working with AJAX from the tutorial at w3schools. I'll use their tutorial to show you my issue.. If you go to http://www.w3schools.com/PHP/php_ajax_database.asp you see the HTML form, the javascript and the php page. I am trying to get the php page to run javascript similarly to this:
The alert doesn't display. Once I can make a javascript alert display from this page I'll be able to do what I really want to do i.e. something involving mouseover().
Can someone please help?..
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
I'm working with AJAX from the tutorial at w3schools. I'll use their tutorial to show you my issue.. If you go to http://www.w3schools.com/PHP/php_ajax_database.asp you see the HTML form, the javascript and the php page. I am trying to get the php page to run javascript similarly to this:
Code: Select all
<html>
<title></title>
<head></head>
<body>
<script type="text/javascript">
alert("test");
</script>
<?php
$q=$_GET["q"];
$con = mysql_connect('localhost', 'peter', 'abc123');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("ajax_demo", $con);
$sql="SELECT * FROM user 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>Job</th>
</tr>";
while($row = mysql_fetch_array($result))
{
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);
?>
</body>
</html>Can someone please help?..
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: