-
PHP alert help needed
Hi All,
I need help on implementing an alert using PHP and MySQL. The following is the plan:
1. User makes a requisition and the manager approves of it.
2. I want the manager to be alerted/notified of an impending requisition in the form of an alert.
The following is what i have done but it's not working:
<?php
require_once("admin/db.php");
$result = @mysql_query("SELECT * FROM users");
if($row['financealert']=='Yes'){
?>
<script type="text/javascript">
windows.alert('ATTENTION');
</script>
<?php
}
?>
Your help is welcome.
Regards.
-
You aren't defining $row in that code - what error did you receive?
-
It just escaped me, i have modified the previous code to the following:
require_once("admin/db.php");
$result = @mysql_query("SELECT * FROM users where username='$uname'");
$row = mysql_fetch_array($result);
if($row['financealert']=='Yes'){
?>
<script type="text/javascript">
windows.alert('ATTENTION');
</script>
<?php
}
?>
Am still not getting the alert after defining the $row.
Regards
-
Put or die(mysql_error()) after you're mysql functions. Is financealert 'Yes' in the first row returns by your query?
-
After placing the die(mysql_error()), the alert still did not come up. financealert 'Yes' is return by query in the database.
require_once("admin/db.php");
$result = @mysql_query("SELECT * FROM users");
$row = mysql_fetch_array($result);
die(mysql_error());
if($row['financealert']=='Yes'){
?>
<script type="text/javascript">
windows.alert('ATTENTION');
</script>
<?php
}
?>
Regards.
-
PHP Code:
<?php
require_once("admin/db.php");
$result = mysql_query("SELECT * FROM users where username='$uname'") or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());
if($row['financealert'] == "Yes"){
?>
<script type="text/javascript">
alert('ATTENTION');
</script>
<?php
}
?>
-
Try
Code:
<?php
require_once("admin/db.php");
$result = @mysql_query("SELECT * FROM users");
$row = mysql_fetch_array($result);
die(mysql_error());
if($row['financealert']=='Yes'){
?>
<script type="text/javascript">
alert('ATTENTION');
</script>
<?php
echo "Got in the IF?";
}
?>
-
-
Pop up alert
Hi all,
I need the PHP code for the following scenario and this is the logic:
If user_session = username
and financealert == 'yes'
pop up an alert.
Your help is much needed.
Regards.
-
You'll need to explain the details a lot more. If you have some code already, please post it. If not, how do you plan to determine those values? Where are they stored? What software are you using?
If you don't have anything (and you don't know how to do it) you may want to ask for paid help for someone to build a whole system for you.
-
The following is my code:
<?php
session_start();
$_SESSION['$username'];
require_once("admin/db.php");
$result = mysql_query("SELECT financealert, username FROM users WHERE financealert='yes'") or die(mysql_error());
if($user_session == $username && $financealert == 'yes') {
?>
<script type="text/javascript">
windows.alert('ATTENTION');
</script>
<?php
}
?>
The alert is not showing anyway.
-
Please only have one thread per problem. What happened with the code I posted in the previous thread?
http://www.dynamicdrive.com/forums/s...ad.php?t=59525
-
If you're still having trouble, something I noticed in the other thread you started is:
Code:
<script type="text/javascript">
windows.alert('ATTENTION');
</script>
<!-- should be: -->
<script type="text/javascript">
alert('ATTENTION');
</script>