I am new to PHP/MySQL and i am making a maintenance screen that i can use to easily create web pages. My maintenance screen lists all the pages with thier titles and some other attributes in a tabular format. onclick of a table row i want the jquery to take the user to another location passing in the page reference. This is not a problem if i hard code the script in the <head> of the page. When i want to make it dynamic using a query even though the code in the source looks identical it doesnt seem to like it, i am hoping it is something simple. See below, Example 1 works fine Example 2 it doesn't like:
EXAMPLE 1:
echo "<script type='text/javascript'src='js/jquery.js'></script>
<script>$(document).ready(function(){
$('tr1').click(function(){
window.location = 'www.google.co.uk';
})
});
</script>";
EXAMPLE 2:
echo "<script type='text/javascript'src='js/jquery.js'></script>
<script>$(document).ready(function(){";
/*== for each page output the attributes ==*/
while ($record = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
echo "$('#tr$record['pageRef']').click(function(){
window.location = 'www.google.co.uk';
})";
echo "});
</script>";
I am using Google Chrome. Let me know if you need any more information.
Thanks
Scott


Sign In
Create Account

Back to top










