PHP - What Is The Simplest Way To Display An Alert With A The Value Of A Php Variable
Using Javascript, how do I do an alert and show the value of a variable?
thanks Similar Tutorials This is my code Code: [Select] $file = $file . $line; fclose($fh); echo "<script language= 'JavaScript'>alert(' . $file . ');</script>"; the alert box is not coming up. Please suggest a way to print the contents of the file in a alert box. Hi all, Thanks for reading. I'm hella frustrated at this script I wrote: for some reason, it will not work correctly. Basically, it works. The first 4 names in the table on the database show up when searched. But, anything past these four names in the database will not show up as a result when searched! I'm pulling my hair out here! It's really simple - take a gander: Code: [Select] if (isset($_POST['submit'])) { $search = $_POST['search']; $searchQuery = mysql_query("SELECT * FROM Accounts WHERE FullName='$search'"); if (mysql_num_rows($searchQuery) == 0) { $result = "Your search returned no results. Please try again."; } else { $results = 1; while ($getSearchResults = mysql_fetch_array($searchQuery)) { $fullName = $getSearchResults['FullName']; $result = "Name: ".$fullName.""; } } } ?> ...and the HTML form... Code: [Select] <form action="search.php" method="post"> <p>Search: <input type="text" name="search" size="35" maxlength="100" /></p> <p><input type="submit" value="Search" name="submit" /></p> <?php echo $result; ?> </form> Does anyone have any ideas? Code: [Select] <?php // plm require_once (dirname(__FILE__) . "/inc/main.php"); $lang = load_language('view_post'); $id = intval($_GET['id']); if ( $id >= 1 ) { dbconn(); // la la la } else { echo "$id\n"; // for debugging die ("no id specified"); } ?>when it's executed of curse i get "0 no id specified" 1. i dont get why i get 0 as a result even if the url is /x.php?id=204 2. in error.log i get Quote PHP Notice: Undefined index: id in x.php i intend to inform that formerly the script was running smoothly on lighttpd webserver, now i use nginx ( so i wont use words ) i know that are people with more complicated things around here ... but still i'm struggling for 1 hour with this xxx thanks in advance btw : php version 5.3.x I'm trying to display an html <div> based on the state of a variable set during php execution . The variable is $chk and is set to either 0 or 1 with 0 meaning failed and 1 meaning pass. Here's the code: if <?php echo "{$chk}";?> == 0 <div class="container"> <div class="row" style="color:red"> <br><br><br><br><br><br> <center>Database Update Failed</center> </div> </div> else <div class="container"> <div class="row"> <br><br><br><br><br><br> <center>Database Updated</center> </div> </div>
Thanks in advance, Larry Edited June 19, 2020 by larry29936additioal info I want to retrieve an image id from a db and show the images. I cant get the syntax right for the image tag.Any help appreciated. Code: [Select] function display_covers() { global $wpdb; $query = "select * from wp_cover"; $result = mysql_query($query)or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); echo mysql_error(); if (!$result) return false; echo'<div class="wrap"><p>choose from one of the covers below</p></div>'; echo'<div id="main">'; echo'<table class="main" cellpadding="2">'; //echo"<caption>Please choose a book cover</caption>"; ?> <thead><tr><td colspan="5" ><h6 class="main">Book Covers</h6></td></tr> </thead> <?php $i=0; $size=3; echo "<tbody>"; echo "<tr>"; while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { /* display picture */ ?> <td class="main"> <?php echo"<img src="/Applications/MAMP/htdocs/wordpress_3/wp-content/plugins/Authors2/jackets/"{.$row['pix'].}""/>"; echo"</td>"; $i++; if($i==$size) { echo "</tr><tr>"; $i=0; } } } So I have these session variables being stored on login. Each page stores these session variables in local PHP variables. For some reason, all pages display that variable in the URL except one page. I have done some 'echo' work just to ensure variables have values stored and that everything was being read appropriately, no issues there. The variables are apparent everywhere on the page besides the URL. Below you can find all the code I have to make this thing work....maybe someone can point me in the right direction because I am STUMPED!!! LOL So my first page calls a popup window in javascript defined below. The link involves the following PHP Code: [Select] $customer_id = $_SESSION['cid']; $customer_email = $_SESSION['cust_email']; $customer_fname = $_SESSION['cust_first_name']; $customer_contact_id = $_SESSION['customer_contact_id']; $customer_company_id = $_SESSION['customer_company_id']; $c_project_id = $_GET['pid']; $c_project_id = mysql_real_escape_string($c_project_id ); $c_project_id = eregi_replace("`", "", $c_project_id); Then comes in the Javascript... Code: [Select] <script type="text/javascript"> <!-- $(document).ready(function(){ $(".approval").click(function(){ v = $(this).attr("id"); url = 'deny_approval.php?cid=<?php echo "$customer_id"; ?>&company_id=<?php echo "$customer_company_id"; ?>&customer_contact_id=<?php echo "$customer_contact_id"; ?>&pid=<?php echo "$customer_project_id"; ?>§ion=' + v; window.open(url, "myWindow", "status = 1, toolbar = no, scrollbars = yes, location = no, resizable = no, height = 600, width = 600, resizable = 0" ); }); }); //--> </script> And finally, the HTML.... Code: [Select] <body> <a href="#" id="deny_quote_approval" class="approval">Deny Quote Approval</a><br /><br /> </body> Any ideas?? As always, any help would be greatly appreciated. Bl4ck Maj1k Hi, i cant seem to get something working, should be simple but its not working for me. I just need to only display a table if a variable in my table = a certain value. The column in the table is called 'option1_available' and if its value is set to 'Y' i want it to display a table. Appreciate any help, Thanks I am building a website that uses session variables extensively. The site is getting a little complicated, and I am starting to lose track of which session variables are assigned, and what their values are. Is there some way where I can create a piece of code that will display all of the existing session variables and their values? Trying to figure out how to make it so name is a link to the profile when its echo anyone know how to do this? im at a huge stand still Code: [Select] <?php $sql = "SELECT name FROM users WHERE DATE_SUB(NOW(),INTERVAL 5 MINUTE) <= lastactive ORDER BY id ASC"; $query = mysql_query($sql) or die(mysql_error()); $count = mysql_num_rows($query); $i = 1; while($row = mysql_fetch_object($query)) { $online_name = htmlspecialchars($row->name); echo '<a href="Inbox.php">"'[$goauld]'</a>"'; ?> I am attempting to us glob to display contents of a users folder using a session variable. Example: I have a session variable called department Code: [Select] $row_fullname['department']; In department I have the name of the department the user belongs to such as: office, plant, maintenance, and groundskeeping I created a folder called docs inside of docs there are 4 subfolders called office, plant, maintenance, and groundskeeping I found this code which will display the contents of the folder: Code: [Select] <?php $files = glob( './docs/office/*.*' ); foreach ( $files as $file ) { echo '<a href="./docs/office/' . basename( $file ) . '"target="_blank">' . basename( $file ) . '</a><br />'; } ?> The above code works fine, but I would like it to only display the contents of a departments folder only if the user is part on that department. Here is an example that I know is completely wrong but it may help explain what I am trying to do. Code: [Select] <?php ]<?php $files = glob( './docs/echo $row_fullname['department'];/*.*' ); foreach ( $files as $file ) { echo '<a href="./docs/echo $row_fullname['department'];/' . basename( $file ) . '"target="_blank">' . basename( $file ) . '</a><br />'; } ?>Thanks for your time I'm trying to make the simplest login and this isnt working can someone explain why? thanks if ($_POST['user'] == 'admin' && $_POST['pass'] != '1234') { echo "fail"; } else { echo "win"; no matter what I do it says win Hello, I had a page that lists the tags in a php page, I had make a link looks like : tag.php?ID=2&action=delete I need to give an alert before the tag being deleted. how can I do this? Thanks Hi, can anybody check on this code? I don't have any errors in it, except that the supposedly alert after I deleted an information is not working. Thank you very much. **This is a modified code provided by a friend. It worked originally (I just lost the original file since I sold my old computer xD Here's the code: <?php include("dbconnection.php"); if(mysql_num_rows($result) > 0) { $query = "SELECT * FROM records WHERE id = '".$_GET["id"]."'"; $result = mysql_query($query, $connection); $status = mysql_result($result, 0, "status"); $territory = mysql_result($result, 0, "territory"); $job_title = mysql_result($result, 0, "job_title"); $area_of_work = mysql_result($result, 0, "area_of_work"); $employer = mysql_result($result, 0, "employer"); $department = mysql_result($result, 0, "department"); $location = mysql_result($result, 0, "location"); $date_posted = mysql_result($result, 0, "date_posted"); $closing_date = mysql_result($result, 0, "closing_date"); $gender = mysql_result($result, 0, "gender"); $first_name = mysql_result($result, 0, "first_name"); $last_name = mysql_result($result, 0, "last_name"); $telephone_number = mysql_result($result, 0, "telephone_number"); $title = mysql_result($result, 0, "title"); $address_1 = mysql_result($result, 0, "address_1"); $address_2 = mysql_result($result, 0, "address_2"); $address_3 = mysql_result($result, 0, "address_3"); $city = mysql_result($result, 0, "city"); $country = mysql_result($result, 0, "country"); $postal_code = mysql_result($result, 0, "postal_code"); $website = mysql_result($result, 0, "website"); $email_address = mysql_result($result, 0, "email_address"); $cg_comment = mysql_result($result, 0, "cg_comment"); $date_emailed = mysql_result($result, 0, "date_emailed"); $mailing_comments= mysql_result($result, 0, "mailing_comments"); $telesales_comments= mysql_result($result, 0, "telesales_comments"); } if(isset($_POST["btnSubmit"])) { $id = $_POST["id"]; $query = "DELETE FROM records WHERE id = '".$id."'"; mysql_query($query) or die(mysql_error()); echo "<script> alert('You have successfully deleted a record'); window.location = 'view_client.php'; </script>"; } ?> This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=317425.0 im trying to get new user messages to show up on my site.. i have looked around on google but can only find info on popup alerts.. i just need a simple javscript code that will display the number of new messages next to the link that takes them to their inbox.. if someone could point me to a site or if they have the code handy i would appreciate it more than you know.. thank you So say I have a page with 3 buttons on:
<button id="1" onclick="clickFunction()">1 </button> <button id="2" onclick="clickFunction()">2</button> <button id="3" onclick="clickFunction()">3</button>How do I then create an alert displaying which was pressed? e.g: <script> function clickFunction() { alert("Button X Was Pressed"); } </script>I know in this case I could create 3 different functions but I want to use it for a page with a lot more than 3. Thanks, This might be more than just a php question but here goes anyways. I have designed a php chat room page on my home Apache server just for a few friends & family. The problem I have is the only way for me to know if anyone is on the chat room page is if I'm actually viewing the php page. Is there a way that I can have the page alert me when someone accesses it? I was thinking something like activating a popup in my browser or even a beep so as long as I'm at my computer with my browser open that I will know someone has accessed the page. Hi, In my attendance system i want to add email alert using php. I want the system to check the records in my db and send email to everyone that forgot to clock-in after 7:30AM from Sunday to Thursday. What i need to use for this, ideas? Hello all; I need to throw up a confirmation alert before allowing a database deletion. Here's the code I wrote: Code: [Select] echo "<a href='task.php?option=delete\"onclick=\"return (confirm('Do you really want to delete this?'));>Delete</a>"; The idea is that the Javascript prevents the .php from completing unless the user Confirms. It works great as .html, but I've clearly done something wrong in the .php version, as it never invokes the alert. Does anyone have any idea where I went so horribly, horribly wrong? Thanks! Kyle Hey all - Below is my code. I'm uncertain how to move correctly code (syntax) what I'm looking to do.. When the user clicks "Next" or "Previous," the following youtube clip will load into the div tag. (With the corresponding description tag). Where do I incorporate the str_replace? And how do I make sure both the youtube clip with the correct description is loaded? Any advice is appreciated! <?php $youtubeIds = array("rHNtuaVHenM","zIAdbIMNq9g","QQ4TlJLa-n4","JccPOA12ELI","JccPOA12ELI", "TWhhXVqVB7E"); $embedCode = '<object width="853" height="505"><param name="movie" value="http://www.youtube.com/v/__YOUTUBE_ID__?fs=1&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/__YOUTUBE_ID__?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="853" height="505"></embed></object>'; if(isset($_GET['youtubeclip'])) { if(is_numeric($_GET['youtubeclip'])) { if($_GET['youtubeclip'] >= 0 && $_GET['youtubeclip'] <= 5) { $youtubeclip = $_GET['youtubeclip']; } else { $youtubeclip = 0; } } else { $youtubeclip = 0; } $prevyoutubeclip = $youtubeclip-1; if($prevyoutubeclip < 0) { $prevyoutubeclip = 5; } $nextyoutubeclip = $youtubeclip+1; if($nextyoutubeclip > 5) { $nextyoutubeclib = 0; } $clip_names= array('Episode #1', 'Episode #2', 'Episode #3', 'Episode #4', 'Episode #5', 'Episode #6'); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Billy Green</title> <link rel="stylesheet" type="text/css" media="screen" href="episode_style.css"> </head> <body> <div class="wrapper"> <?php include 'header.php'?> <div id="episode_content"> <div class="youtube_box"> <?php echo $embedCode; ?> </div> <h2 class="clip-description">"<?php echo $clip_names[$youtubeclip]; ?>" </h2> <div class="youtube_control"> <a href="episodes.php?youtubeclip=<?php echo $prevyoutubeclip; ?>"> Previous Clip </a> <a href="episodes.php?youtubeclip=<?php echo $nextyoutubeclip; ?>"> Next Clip </a> </div> </div> <div class="clearIt"> </div> <?php include 'footer.php'?> </div> </body> </html> |