PHP - Reload Div In A Function
I have a div that displays the contents of a mysql table. When the users adds to the table/presses a button I want it to fade out, reload, and fade back in with the new content there.
The current PHP code is in its own div called 'stream'... <script> function buttonFunction() { v=$("#txtstatus"); $.post('../action/poststatus.php',{status:v.val()},function(d){ $('div#stream').fadeOut('slow'); $('div#stream').load; $('div#stream').fadeIn('slow'); }); } </script>This fades out and back in but with nothing new loaded. Please help. Thanks, Similar TutorialsI had another thread about a problem I was having where it's not loading from the DB right aways. My solution is to make an update function and then have the id's calling it on the page. So the thing I am wondering is how to make a working update function. I have this so far: <?php include blah.... $uid = $_SESSION["user"][0]; $avatarid = $_SESSION["user"][12]; function update($str) { global $db_id; $query="select ".$str." from users where id=".$uid; $result=mysql_query($query, $db_id); $row=mysql_fetch_row($result); return $row[0]; } ?> and then it's being called on the profile page with <?php echo update($avatarid); ?>. I want the update() function to select avatar from users where id = userid and then return the value fresh so it's getting it new from the database every time they refresh the page. Then there won't be a problem with updating old avatar stuff. Currently gives me the error: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/root/public_html/func.php on line 69 So what am I doing wrong here? thanks for anyone who can help I am creating a 'stream' page with like buttons under each status. It works untill the div is reloaded with new content. I have researched this and it appears to be due to the new content not being loaded into the DOM. Does anyone know a solution? I have found a few strange ones, for example, forcing a window resize. I tried that but it didn't work. Thanks, Hi is there any way we can prevent suppose <textarea></textarea> when page reload it refresh and set default text i wanted to know is there any way to prevent certain things not to get refreshed is there any method in php which prevent to reload this ! <?php echo "<textarea > Enter your favorite quote!</textarea> \n" ; Code: [Select] if (isset($_GET['edit']) && $_GET['edit'] == 'textupdate'){ } <a href= \"{$_SERVER['PHP_SELF']}?page=1&edit=textupdate \" >Click</a>?> Hi I have this script i wrote which show four random business from my database inline. Now I want this script to show the four results for 5 seconds and then show another 4 businesses for 5 seconds and so on. Can someone please point me in the right direction as to what I need to be looking up to do this as I dont know where to begin. here is the code by the way <?php $qGetUsers = "SELECT * FROM business ORDER BY rand() LIMIT 4"; $rGetUsers = mysql_query($qGetUsers) or die(mysql_error()); while($allUsers = mysql_fetch_array($rGetUsers)) { ?> <table id="top4tbl" width="150px" height="141px" border="0" cellpadding="0" cellspacing="5"> <tr> <td width="150" ><div align="center"><img src="<?php echo $allUsers['image_location'];?>" /> </div></td> </tr> <tr> <td width="150" ><div align="center"><strong><?php echo $allUsers['Business_name'];?> </strong></div></td> </tr> <tr> </tr> <tr> <td width="150" height="20"><div align="center"><a href="businessinformation.php?businessid=<?php echo $allUsers['businessid'];?>">More Info</a></div></td> </tr> </table> <?php } ?> Hi, i'm kind of new with php. i need to make some easy script, that get link of XML file and another "number". and reload the XML file "number" of times. i need to do it with $_GET function. if someone will help me it`ll be greate. Thanks, Or. hello guys, i have a question, in some php files i have in the start <? ob_start(); ?> <?php session_start(); ........ ..... ...... if(isset($_POST['sub_1'])) { $_SESSION['address_tmp']=$_SESSION['address_tmp']." oK "; header("location:some_other_page.php#jumpselection"); } if(isset($_POST['sub_2'])) { $_SESSION['address2_tmp']=$_SESSION['address2_tmp']." hello "; header("location:thispage.php#jumpselection"); } ?> <body> <form method="post" action=""> <input type="Submit" name="sub_1" value="action1"style="height:3.9em; width:16.5em; font-size:95%;"> </form> </body> <body> <form method="post" action=""> <input type="Submit" name="sub_2" value="action2"style="height:3.9em; width:16.5em; font-size:95%;"> </form> </body> <? ob_end_flush(); ?> but every page have 10-15 buttons every button in the end reloads the same page with header("location:thispage.php#jumpselection"); or cals another page with header("location:some_other_page.php#jumpselection"); this works but i notise some lag on the bowser afrer while.. I would like the page orderform.php to reload or refresh to normal after I click this link: this is what i have and this link is on a different page though... if($myError==true) echo "<br /><br />Click here to <a href='orderform.php?nocache='.time().'>go back...</a>"; else header("location: orderform.php"); aside from file_get_contents(); is there a way to reload a header quicker than that file_get_contents offer? How would I set up a HEAD request to load a header? Thanks For those willing to run this sample problem, reference the 2 files below. You will need to create an Excel file called blank.xls and put it in the same directory as these 2 files. When you launch indexTest.php, it will load the formTest.html.php page. This form has 3 options on it: 1. Export Excel - will prompt you to download the Excel file you made and should clear the error message on the form 2. Test Flag - tests the functionality of clearing the error message, shows what should happen when the Export Excel option is selected 3. Reset - resets back to initial state I really need the Export Excel option to be allow the form to reload properly. This is a problem that I have been wresting with for awhile and need a solution. Hopefully someone can give me some insight on how to get this to work. indexTest.php <?php $frmErrorLevel=1; $frmErrMsg='Error Level 1 indicated'; if(isset($_POST['action']) && $_POST['action']=='submitted') { if(isset($_POST['ExportCarrier'])) { $download_filename = "blank.xls"; $FileInfo = pathinfo($download_filename); // fix for IE catching or PHP bug issue header("Pragma: public"); header("Expires: 0"); // set expiration time header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); // browser must download file from server instead of cache // force download dialog header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-type: application/x-msexcel"); header("Content-Type: application/download"); // use the Content-Disposition header to supply a recommended filename and // force the browser to display the save dialog. header("Content-Disposition: attachment; filename=".$download_filename.";"); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($download_filename)); @readfile($download_filename); //ob_end_clean(); $frmErrorLevel=0; } if(isset($_POST['Test_Flag']) && $_POST['Test_Flag']=='Test Flag'){ $frmErrorLevel=0; $frmErrMsg=''; } } include ('formTest.html.php'); exit(); ?> formTest.html.php <?php ini_set ("display_errors", "1"); error_reporting(-1); echo "<pre>"; echo "--> Form data (POST) <-- <br>"; print_r ($_POST); echo "--> Form data (GET) <-- <br>"; print_r ($_GET); echo "</pre>"; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Export Trucking Data</title> </head> <body> <h1>Export Data</h1> <form action="" method="post"> <?php if($frmErrorLevel>0) { echo '<font color=#CC6600 size=+1>'.$frmErrMsg.'</font><br><br>'; } ?> <table width="650" border="0"> <caption> <font size="+3">Data Export Options</font> </caption> <tr> <td> <?php if($frmErrorLevel==1) print '<img src= "..\..\images\rdx.gif">'; else echo " "; ?> </td> <td width="275"><label> Carrier table data</label></td> <td width="100"><input name="ExportCarrier" type="submit" value="Export Excel"></td> <td> <div align="center"> <td><input type="submit" name="Test Flag" value="Test Flag"></td> <td> <div align="center"> <td><input type="submit" name="Reload Form" value="Reset"></td> </tr> </table> <div> <input type="hidden" name="action" value="submitted" /> </div> </form> </body> </html> Can someone help me with a code , which can make a select form to reload the page or the form in the moment when a option from it , is been selected.
i try it whit onClick="document.location.reload()"; but doesn't work properly.
thx
Ok, so I am trying to make a database with PHP and I hit a snag. First off, here is the code in question. Code: [Select] <?php //GET CONFIG include_once('../scripts/config.inc.php'); //SET VARIABLES TO SOMETHING A BIT SHORTER FOR THE DATABASE OPTIONS $host = $config['db_settings']['db_host']; $user = $config['db_settings']['db_user']; $pass = $config['db_settings']['db_pass']; $prefix = $config['db_settings']['db_prefix']; $db = $config['db_settings']['db_name']; $con = mysql_connect($host, $user, $pass); $select_db = mysql_select_db($db); $c_tables = ''; $c_database = "CREATE DATABASE IF NOT EXISTS $db;"; //NOW CONNECT TO THE SERVER if ($con){ echo('Connected Succesfully to the Server <br />'); } else die('Could not connect to database: ' . mysql_error()); //NOW CONNECT TO THE DATABASE if ($select_db){ echo('Selected Database Succesfully <br />'); } //IF DATABASE COULD NOT BE SELECTED THEN TRY TO MAKE IT else if(!$select_db){ echo('Could not select the databse. Trying to create it... <br />'); if(mysql_query($c_database)){ echo('Database has been created...<br />'); if($select_db){ echo('Database Has Been Selected.'); } else die('Can not select database!' . mysql_error()); } else die('Could not created the database!'); } else die ('Could not create or select the database!: ' . mysql_error() . '<br />'); //NOW CREATE THE TABLES mysql_close; ?>The problem is, that if I drop the database to test that it creates the database, it does indeed make it, but after it makes the database it will not select it until I reload the page and intern the script. So this is the output I would get. (The fact that there is no error is what is causing me to be confused) 1st load that makes new database: Quote Connected Succesfully to the Server Could not select the databse. Trying to create it... Database has been created... Can not select database! 2nd load that should not be needed to select the database: Quote Connected Succesfully to the Server Selected Database Succesfully Hi all, I have a listbox on a form that gets it's data from a MySQL query, all of which is working fine. I make a selection in my listbox and then submit the form which is reloading itself. However on the reload I would like the listbox to display the selection made by the user, instead it reverts to the first item in the list. I have included the code, if someone could point me in the right direction that would be great. I have searched these forums and tried a few things that are suggested but I still can't get it to work. Code: [Select] <?php include("dbconn.php"); $query = "SELECT location.location_name, printer.model_number, location_printer.serial_number" . " FROM location, printer, location_printer" . " WHERE location.location_id = location_printer.location_id" . " AND printer.printer_id = location_printer.printer_id"; $result = mysql_query($query); echo "<table>"; echo "<th>Location</th>"; echo "<th>Printer</th>"; echo "<th>Serial No</th>"; while(($row = mysql_fetch_array($result))) { echo "<tr>"; echo "<td>".$row['location_name']."</td>"; echo "<td>".$row['model_number']."</td>"; echo "<td>".$row['serial_number']."</td>"; echo "</tr>"; } echo "</table>"; if(isset($_POST['location'])) { $loc = $_POST['location']; echo "<p>Location = <b> $loc </b>"; } ?> <html> <head> <title>Loop Results</title> </head> <body> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" > <table> <tr> <td> <?php $query = "SELECT * FROM location ORDER BY location_name"; $result = mysql_query($query); $default = $_POST['location']; echo "<p>Location: "; echo "<select name='location'>"; while(($row = mysql_fetch_array($result))) { echo "<option value='{$row['location_id']}"; //Selected value if($row['location_id'] == $default) echo " selected "; echo "'>{$row['location_name']}</option>\n"; } echo "</select>"; ?> </td> </tr> <tr> <td> <input type="submit" /> </td> </tr> </table> </form> </body> </html> I have an html table that is being populated with links from a specific directory.. I would like the user to be able to click the link and if its a file they will download the file. If its a directory, I woudl like to reload the current page but this time show the contents of the directory. My main issue is that I have a session variable called 'workingdirectory' that I need to update before I reload the page. I have tried setting it and then calling Location('page.php') but I get the 'cannot change header information' error. I realized I was getting this because I had begun to call HTML code before the PHP was finished. Is there a way to just simply update the session variable, and then make the page reload when the user clicks on a link? Hello dear friends, I've very annoying problem my website is for child drawing (draw.php) after child do drawing will click on submit (form) by sending it to another page (thanks.php) | | | | data will be submitted to database and gives message saying ( thank you for ...blah blah blah) here is the problem if he refresh the page , it will also add entry to the database so imagine if someone did many many refresh, i will get many many empty entry into database how to stop this ? here is simple code based on this problem Code: [Select] <form name="frm" method="post" action="thanks.php"> <input type="text" name="name" id="name" value=""> <input type="text" name="email" id="email" value=""> <button type="submit">Submit</button> </form> and the (thanks.php) file code *assume we have connection to db Code: [Select] $sql = "INSERT INTO $table (name, email) VALUES ('$name', '$email')"; mysql_query($sql, $conn) or die(mysql_error()); echo "Thank you kid..nice drawing"; now my problem if (thanks.php) got refreshed it will also will add empty entry to database can anyone please help me how to stop it. The Script:
<h1>Do Add a Message to the MySQL Database</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <textarea name="message"></textarea> <br/> <input type="submit" name="submit"/> </form> <?php // The Connection to the Database // Taken Out ?> <?php // To insert the text data into the MySQL database. if(isset($_POST['submit'])){ $tqs = "INSERT INTO messages (`message`) VALUES ('{$_POST['message']}')"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); } ?> <?php // To select the text data from the MySQL database. $tqs = "SELECT * FROM messages"; $tqr = mysqli_query($dbc, $tqs); // To print out the text data inside of table on the page. echo "<h1>This Is Where the Messages Gets Printed on Screen</h1>"; echo "<table><tr><td>ID</td><td>The Message</td></tr>"; while($row = mysqli_fetch_assoc($tqr)){ echo "<tr><td>" . $row['id'] . "</td><td>" . $row['message'] . "</td></tr>"; } echo "</table>"; ?>1. When I have added text with the form to the MySQL database... 2. ... and I have clicked on "page reload" in Firefox to reload the page... 3. ... then the before submitted text gets submitted again to the MySQL database. So basically, add text with the form to the MySQL database, reload the page in Firefox, and the before added text will get submitted to the MySQL database again. My Question Is: What is the proper way to avoid this? Edited by glassfish, 06 October 2014 - 10:18 AM. This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=346243.0 Hello, I am having issues with getting cookies to function how i'd like them to. My goal is to be able to capture a cookie value from the url if a user comes to my site via something like adwords. An example URL they could come to is http://www.mysite.com?kw=hello I am trying to capture the word 'hello' and tie it to that visitor regardless of where they go on the site. I need to use that value to pass through if they complete a form on my site so that i can track the keyword source. I have included the following as the first line of code on every page of my site: Code: [Select] $kw = $_GET["kw"]; setcookie('kw',$kw); Then, if i go to this url: http://www.mysite.com?kw=hello and then later go to a url like this: http://www.mysite.com/page1.html, i am able to echo out the cookie on page1.html using the following code which is contained in page1.html: Code: [Select] echo $_COOKIE["kw"]; The problem is, if i then refresh page1.html i can no longer echo out the cookie--it disappears. I need the cookie to stay with the user no matter what page they are on within the site and not matter how many different pages they visit. I hope i am explaining myself in a way someone can understand. Perhaps cookies aren't the best way? Should i use sessions instead? Thanks in advance for your help I am not very advanced in web programming I need help..
I am using an API and my sql database. I would to implement live/ dynamic updates in the text field where user will input their text, and the web should first check the database then the api live. I would also like to retrieve the user input without refreshing the page, so the retrieved information regarding the inputted text should be automatically loaded without refreshing the page.
please help .
Hi guys, I am having a real problem with this and I can't figure it out. I am not that much of a techie so take it easy on me. I am building a survey form for a website to get feedback on the service, and naturally it can fail validation if the email address is misspelled or the security question is answered wrong. Retaining text values was easy and I managed to dig around for some solutions to retain radio button values. The problem is IT ONLY WORKS ON ONE OPTION! I tried everything including coming up with completely separate value names, yet the page still loads with all radio options set to the same shared value (usually of the last radio button question). Here is my code: <?PHP $Excellent_status = 'unchecked'; $VeryGood_status = 'unchecked'; $Satisfactory_status = 'unchecked'; $Weak_status = 'unchecked'; $Horrible_status = 'unchecked'; if (isset($_POST['send'])) { $selected_tk = $_POST['tk']; if ($selected_tk == 'Excellent') { $Excellent_status = 'checked'; } else if ($selected_tk == 'VeryGood') { $VeryGood_status = 'checked'; } else if ($selected_tk == 'Satisfactory') { $Satisfactory_status = 'checked'; } else if ($selected_tk == 'Weak') { $Weak_status = 'checked'; } else if ($selected_tk == 'Horrible') { $Horrible_status = 'checked'; } } $Excellent2_status = 'unchecked'; $VeryGood2_status = 'unchecked'; $Satisfactory2_status = 'unchecked'; $Weak2_status = 'unchecked'; $Horrible2_status = 'unchecked'; if (isset($_POST['send'])) { $selected_ts = $_POST['ts']; if ($selected_ts == 'Excellent') { $Excellent2_status = 'checked'; } else if ($selected_ts == 'VeryGood') { $VeryGood2_status = 'checked'; } else if ($selected_ts == 'Satisfactory') { $Satisfactory2_status = 'checked'; } else if ($selected_ts == 'Weak') { $Weak2_status = 'checked'; } else if ($selected_ts == 'Horrible') { $Horrible2_status = 'checked'; } } ?> <h1 align="center">Feedback Form:</h1> <p align="center">We highly value your input. Your feedback can help us serve you better and provide you with a holistic experience that meets or exceeds all your expectations. <br /> Please take the time to fill out the form below.</p> <br /> <br /> <p align="center"><strong>(Fields marked with a <span class="required">*</span> are necessary. The course information is to validate which course and batch the survey is regarding, and the name and email allows our admin to verify the details and gain more information from you if needed)</strong></p> <p align="center"><strong>The identity in this form is strictly confidential, and it will not be revealed to course trainer, co-ordinator, or your sponsor.</strong></p> <!--Error Message--> <?php echo $error;?> <form method="post" name="contFrm" id="contFrm" action=""> <label><span class="required">*</span>Name:</label> <input name="name" type="text" class="box" id="name" size="40" value="<?php echo $name;?>" /><br /> <label><span class="required">*</span>Email: </label> <input name="email" type="text" class="box" id="email" size="40" value="<?php echo $email;?>" /><br /> <label><span class="required">*</span>Course attended: </label> <input name="course" type="text" class="box" id="course" size="40" value="<?php echo $course;?>" /><br /> <label><span class="required">*</span>Course Date and City: </label> <input name="dateplace" type="text" class="box" id="dateplace" size="40" value="<?php echo $dateplace;?>" /><br /><br /><br /> <table width="980" border="1" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td width="280" align="left" bgcolor="#285A80"><strong><font color="#FFFFFF" size="+1">Attribute</font></strong></td> <td width="115"> <div align="center">EXCELLENT! </div></td> <td width="115"> <div align="center">Really Good. </div></td> <td width="115"> <div align="center">Satisfactory. </div></td> <td width="115"> <div align="center">Weak, needs attention. </div></td> <td width="115"> <div align="center">Horrible! Unacceptable. </div></td> </tr> <tr> <td width="280" align="left" bgcolor="#71C4CD"><strong><font color="#333333">Trainer Knowledge</font></strong></td> <td> <div align="center"> <input type="radio" name="tk" id="Excellent" value="Excellent" <?PHP print $Excellent_status; ?>/> </div> </td> <td> <div align="center"> <input type="radio" name="tk" id="VeryGood" value="VeryGood" <?PHP print $VeryGood_status; ?>/> </div> </label></td> <td> <div align="center"> <input type="radio" name="tk" id="Satisfactory" value="Satisfactory" <?PHP print $Satisfactory_status; ?>/> </div> </td> <td> <div align="center"> <input type="radio" name="tk" id="Weak" value="Weak" <?PHP print $Weak_status; ?>/> </div> </td> <td> <div align="center"> <input type="radio" name="tk" id="Horrible" value="Horrible" <?PHP print $Horrible_status; ?>/> </div> </td> </tr> <tr> <td width="280" align="left" bgcolor="#71C4CD"><strong><font color="#333333">Trainer Style and Presentation</font></strong></td> <td> <div align="center"> <input type="radio" name="ts" id="Excellent2" value="Excellent2" <?PHP print $Excellent2_status; ?>/> </div> </td> <td> <div align="center"> <input type="radio" name="ts" id="VeryGood2" value="VeryGood2" <?PHP print $VeryGood2_status; ?>/> </div> </label></td> <td> <div align="center"> <input type="radio" name="ts" id="Satisfactory2" value="Satisfactory2" <?PHP print $Satisfactory2_status; ?>/> </div> </td> <td> <div align="center"> <input type="radio" name="ts" id="Weak2" value="Weak2" <?PHP print $Weak2_status; ?>/> </div> </td> <td> <div align="center"> <input type="radio" name="ts" id="Horrible2" value="Horrible2" <?PHP print $Horrible2_status; ?>/> </div> </td> </tr> </table> <br /><br /> <label>Particularly positive points you appreciated: </label> <textarea name="message1" cols="80" rows="3" id="message1"><?php echo $message1;?> </textarea><br /> <label>Particularly negative points you found disappointing: </label> <textarea name="message2" cols="80" rows="3" id="message2"><?php echo $message2;?> </textarea><br /> <label>Any specific message you would like to provide us: </label> <textarea name="message3" cols="80" rows="3" id="message3"><?php echo $message3;?> </textarea><br /> <label><span class="required">* Security Question</span></label><? require_once ("ClassMathGuard.php"); MathGuard::insertQuestion(); ?> <br /> <br /> <!-- Submit Button--> <input name="send" type="submit" class="button" id="send" value="" /> </form> Fact is there are 8 questions (all multiple choice with radio button answers) but I decided to save you a long code read. Basically what I get is that despite choosing different answers for each question, the retention is only of the last option or question, and all the above question choices are set to that choice button. What is wrong? |