phpbigenner Posted July 11, 2013 Share Posted July 11, 2013 <?php $act = $rs['actorID']; $m=mysql_query("SELECT * FROM movie_actor where actorID = '$act'"); $ma = mysql_num_rows($m); if($ma!=0){ echo '<script>alert("Cannot be deleted!")</script>'; }else{ echo '<td style="text-align:center"><a href="delete_actor.php?ID='.$row['actorID'].'" onclick="confirmation();return false"> <img height="40" width="40" src="icons/xx.png" /></a> </td> '; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/280084-why-is-my-echo-alertcannot-be-deleted-is-not-working/ Share on other sites More sharing options...
fastsol Posted July 11, 2013 Share Posted July 11, 2013 Does <script>alert("Cannot be deleted!")</script> actually get echoed if you view the page source after the page loads? If it is there, what doctype are you using? I am no pro javascript guy by any stretch of the meaning but I believe that in most doctypes besides html5 you need to specifiy type="text/javascript" in the <script>, not sure if not having that will make it not work but worth a try. Quote Link to comment https://forums.phpfreaks.com/topic/280084-why-is-my-echo-alertcannot-be-deleted-is-not-working/#findComment-1440381 Share on other sites More sharing options...
Irate Posted July 11, 2013 Share Posted July 11, 2013 Try putting in a <meta name="content-script-type" content="text/javascript"> in your head section before the scripts, otherwise do as fastsol said. Quote Link to comment https://forums.phpfreaks.com/topic/280084-why-is-my-echo-alertcannot-be-deleted-is-not-working/#findComment-1440384 Share on other sites More sharing options...
phpbigenner Posted July 11, 2013 Author Share Posted July 11, 2013 still not working. Quote Link to comment https://forums.phpfreaks.com/topic/280084-why-is-my-echo-alertcannot-be-deleted-is-not-working/#findComment-1440386 Share on other sites More sharing options...
phpbigenner Posted July 11, 2013 Author Share Posted July 11, 2013 (edited) <?php session_start();?> <?php require_once("connect.php");?> <?php if(isset($_COOKIE["header"])){ if($_COOKIE["header"]=="admin") { include("header_admin.php"); } else { include("header_logout.php"); } } elseif($_COOKIE["header"]==NULL){ if($_SESSION['header']=="user"){ include("header_logout.php"); echo "<meta http-equiv='refresh' content='0;url=home.php'>"; } elseif($_SESSION['header']=="admin"){ include("header_admin.php"); } else{ include("header_login.php"); echo "<meta http-equiv='refresh' content='0;url=home.php'>"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="content-script-type" content="text/javascript"/> <title>Star Theater</title> <link rel="shortcut icon" href="images/favicon.ico" /> <link rel="stylesheet" media="screen" href="css/demo.css" /> <link rel="stylesheet" type="text/css" href="css/table.css"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript"> <!-- function confirmation() { var msg = "Are you sure you want to delete this lead actor/actress?"; var answer = confirm(msg); if (answer){ alert('Record successfully deleted!') document.frm.submit(); } } </script> <script> function myFunction() { alert("ayus"); } </script> <style> .highlighted { background:#090; } </style> </head> <body> <div id="content"> <div align="right"><a href="f.actor_add.php" > <img src="icons/ad.png" width="70px" height="70px" title="Add new actor" /></a> </div> <table class="filterable" id="bordered"> <thead> <tr> <th style="text-align:center">Lastname</th> <th style="text-align:center">Firstname</th> <th style="text-align:center">Date of birth</th> <th style="text-align:center">Contact number</th> <th style="text-align:center">Address</th> <th style="text-align:center">VIEW</th> <th style="text-align:center">EDIT</th> <th style="text-align:center">DELETE</th> </tr> </thead> <tbody> <?php include('conn.php'); $result = mysql_query("SELECT * FROM actor order by lname")or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo "<tr>"; echo '<td>' . $row['lname'] . '</td>'; echo '<td>' . $row['fname'] .'</td>'; echo '<td style="text-align:right">' . $row['dob'] . '</td>'; echo '<td style="text-align:right">' . $row['contact_no'] . '</td>'; echo '<td>' . $row['address'] . '</td>'; echo '<td style="text-align:center"><a href="view_actor.php?ID='.$row['actorID'].'"><img height="40" width="40" src="icons/view.png"/></a> </td> '; echo '<td style="text-align:center"><a href="f.actor_edit.php?ID='.$row['actorID'].'"><img height="40" width="40" src="icons/ed.png" /></a> </td> '; $act = $rs['actorID']; $m=mysql_query("SELECT * FROM movie_actor where actorID = '$act'"); $ma = mysql_num_rows($m); if($ma!=0){ echo '<script type="text/javascript">alert("Cannot be deleted!")</script>'; }else{ echo '<td style="text-align:center"><a href="delete_actor.php?ID='.$row['actorID'].'" onclick="confirmation();return false"> <img height="40" width="40" src="icons/xx.png" /></a> </td> '; } echo "</tr>";}?> </tbody> </table> <script type="text/javascript" src="js/tablesearch.js"></script> </div><!-- /content --> <div id="footer"> <label>© <a href="https://www.facebook.com/CodeWEBB.Design?fref=ts">CodeWEBB Design</a></label> |<a href="developers.php"> Developers</a> </div><!-- /footer --> </body> </html> Edited July 11, 2013 by Maq Quote Link to comment https://forums.phpfreaks.com/topic/280084-why-is-my-echo-alertcannot-be-deleted-is-not-working/#findComment-1440387 Share on other sites More sharing options...
phpbigenner Posted July 11, 2013 Author Share Posted July 11, 2013 my whole code now. Quote Link to comment https://forums.phpfreaks.com/topic/280084-why-is-my-echo-alertcannot-be-deleted-is-not-working/#findComment-1440388 Share on other sites More sharing options...
Maq Posted July 11, 2013 Share Posted July 11, 2013 Please use code tags in the future. Quote Link to comment https://forums.phpfreaks.com/topic/280084-why-is-my-echo-alertcannot-be-deleted-is-not-working/#findComment-1440391 Share on other sites More sharing options...
fastsol Posted July 12, 2013 Share Posted July 12, 2013 I don't see anything that stands out as an issue in your code. Again, are you sure that <script> tags are actually being echoed to the page? Run your page in the browser and then do a view page source and see if they are in there. You could also post the view source result here and we can take a look. Quote Link to comment https://forums.phpfreaks.com/topic/280084-why-is-my-echo-alertcannot-be-deleted-is-not-working/#findComment-1440448 Share on other sites More sharing options...
phpbigenner Posted July 12, 2013 Author Share Posted July 12, 2013 (edited) the script didn't echoed. Edited July 12, 2013 by phpbigenner Quote Link to comment https://forums.phpfreaks.com/topic/280084-why-is-my-echo-alertcannot-be-deleted-is-not-working/#findComment-1440458 Share on other sites More sharing options...
phpbigenner Posted July 12, 2013 Author Share Posted July 12, 2013 (edited) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Star Theater</title> <link rel="shortcut icon" href="images/favicon.ico" /> <link rel="stylesheet" media="screen" href="css/demo.css" /> </head> <body> <div id="demo-header"> <a id="login-link" href="logout_process.php" title="Logout">Logout</a> <div id="login-panel"> </div><!-- /login-panel --> </div><!-- /demoheader --> <br class="clear" /><br /><br /><br /> <div id="content"> <h1 class="pagehead"></h1> <ul id="menu"> <li><a href="home.php">Home</a></li> <li><a href="#">Maintenance</a> <ul> <li><a href="theater.php">Theater</a></li> <li><a href="director.php">Director</a></li> <li><a href="actor.php">Lead Actor/Actress</a></li> <li><a href="genre.php">Genre</a></li> <li><a href="schedule.php">Time Scheduling</a></li> <li><a href="price.php">Price</a></li> <li><a href="movie.php">Movie</a></li> <li><a href="viewer.php">Viewer</a></li> <li><a href="slideshow.php">Slide Show</a></li> </ul> </li> <li><a href="#">Transactions</a> <ul> <li><a href="reservation.php">Reservation</a></li> <li><a href="billing.php">Billing</a></li> <li><a href="waitlist.php">Wait list</a></li> </ul> </li> <li><a href="#">Utility</a> <ul> <li><a href="user.php">User</a></li> <li><a href="discount.php">Discount</a></li> </ul> </li> <li><a href="#">Reports</a> <ul> <li><a href="sale.php">Sales</a></li> </ul> </li> <li><a href="faq">Frequently Ask Questions</a></li> <li><a href="about.php">About Us</a></li> </ul> </div><!-- /content --> <!--</div> </div> --> </body> </html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Star Theater</title> <link rel="shortcut icon" href="images/favicon.ico" /> <link rel="stylesheet" media="screen" href="css/demo.css" /> <link rel="stylesheet" type="text/css" href="css/table.css"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript"> <!-- function confirmation() { var msg = "Are you sure you want to delete this lead actor/actress?"; var answer = confirm(msg); if (answer){ alert('Record successfully deleted!') document.frm.submit(); } } </script> <style> .highlighted { background:#090; } </style> </head> <body> <div id="content"> <div align="right"><a href="f.actor_add.php" > <img src="icons/ad.png" width="70px" height="70px" title="Add new actor" /></a> </div> <table class="filterable" id="bordered"> <thead> <tr> <th style="text-align:center">Lastname</th> <th style="text-align:center">Firstname</th> <th style="text-align:center">Date of birth</th> <th style="text-align:center">Contact number</th> <th style="text-align:center">Address</th> <th style="text-align:center">VIEW</th> <th style="text-align:center">EDIT</th> <th style="text-align:center">DELETE</th> </tr> </thead> <tbody> <tr><td>adf</td><td>jake</td><td style="text-align:right">07/11/2013</td><td style="text-align:right">321</td><td>das</td><td style="text-align:center"><a href="view_actor.php?ID=4"><img height="40" width="40" src="icons/view.png"/></a> </td> <td style="text-align:center"><a href="f.actor_edit.php?ID=4"><img height="40" width="40" src="icons/ed.png" /></a> </td> <td style="text-align:center"><a href="delete_actor.php?ID=4" onclick="confirmation();return false"> <img height="40" width="40" src="icons/xx.png" /></a> </td> </tr> </tbody> </table> <script type="text/javascript" src="js/tablesearch.js"></script> </div><!-- /content --> <div id="footer"> <label>© <a href="https://www.facebook.com/CodeWEBB.Design?fref=ts">CodeWEBB Design</a></label> |<a href="developers.php"> Developers</a> </div><!-- /footer --> </body> </html> Edited July 12, 2013 by phpbigenner Quote Link to comment https://forums.phpfreaks.com/topic/280084-why-is-my-echo-alertcannot-be-deleted-is-not-working/#findComment-1440460 Share on other sites More sharing options...
trq Posted July 12, 2013 Share Posted July 12, 2013 Use tags when posting code. Quote Link to comment https://forums.phpfreaks.com/topic/280084-why-is-my-echo-alertcannot-be-deleted-is-not-working/#findComment-1440461 Share on other sites More sharing options...
fastsol Posted July 12, 2013 Share Posted July 12, 2013 the script didn't echoed. Well there ya go, you need to figure out why it's not echoing the tag. You have something wrong in your php logic. Quote Link to comment https://forums.phpfreaks.com/topic/280084-why-is-my-echo-alertcannot-be-deleted-is-not-working/#findComment-1440464 Share on other sites More sharing options...
phpbigenner Posted July 12, 2013 Author Share Posted July 12, 2013 okay. i'll try to figured it out. Quote Link to comment https://forums.phpfreaks.com/topic/280084-why-is-my-echo-alertcannot-be-deleted-is-not-working/#findComment-1440466 Share on other sites More sharing options...
phpbigenner Posted July 12, 2013 Author Share Posted July 12, 2013 I got it men. thankyou. @ fastsol Quote Link to comment https://forums.phpfreaks.com/topic/280084-why-is-my-echo-alertcannot-be-deleted-is-not-working/#findComment-1440476 Share on other sites More sharing options...
fastsol Posted July 12, 2013 Share Posted July 12, 2013 Glad you got it working! You just have to remember to start with the baiscs of diagnostics to figure out a problem. Quote Link to comment https://forums.phpfreaks.com/topic/280084-why-is-my-echo-alertcannot-be-deleted-is-not-working/#findComment-1440487 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.