Search the Community
Showing results for tags 'function'.
-
Hi there i have recently started working with php so I will probably be a familiar name around here. I have been giving a task that I have got a bit stuck with. To give a brief overview I have products that are stocked in x number of warehouses, when a customer places an order depending on their location I will ship from the warehouse that is closest to them if it has all products in stock. I have the following two arrays The first represents a customers order containing the id of the product and the quantity they have selected. e.g. product id:35659, qty:1 Array ( [35659] => 1 [35699] => 1 [35734] => 2 ) The second array shows the quantity in stock for each product in each 3 warehouses that stock it e.g. 35659 being the product id, [9][114][126] being the warehouse and 10,1,0 being the quantity of stock for that item in the warehouse. Array ( [35659] => Array ( [9] => 10 [114] => 1 [126] => 0 ) [35699] => Array ( [9] => 8 [114] => 0 [126] => 5 ) [35734] => Array ( [9] => 10 [114] => 0 [126] => 0 ) ) function check_warehouse_stock($order=array(), $stock=array(), $warehouse=0) { foreach($order as $id => $qty) if($stock[$id][$warehouse] < $qty) return false; return true; } // $warehouses is an array of my warehouses already in their preference order foreach($warehouses as $w) { if(check_warehouse_stock($order, $stock, $w)) break; $w = false; } // $w is now the first warehouse with all the stock, or false if no warehouses have any stock So far I have got the above code which loops through each warehouse and goes into a function that checks each item in their order and sees if any item in their basket is below the quantity in the warehouse, if no items is below the quantity it returns true and that is the first warehouse with all items in stock, if no warehouse has all items in stock it returns false. This is where I am getting stuck, if no warehouse has all items in stock I need to go into a similar function and have some sort of rule that checks if no one warehouse has all products in stock I will ship from wherever has each product in stock starting with the closest and so on... e.g. if the first warehouse had 2 of the 3 items in stock and the second warehouse had 1 in stock we would ship 2 products from the first and 1 from the second. Any help would be greatly appreciated, even with just the logic on how to approach this. Thanks
-
Hello! Second post here. I'm new to PHP and have an idea of what needs to be done, but im not sure the best way to impliment it. Basically im looking for direction on whether I should use JS, AJAX, Jquery, or something else. from browsing around im guessing its going to be a combination of AJAX and Jquery to get this accomplished. Please advise on the best method to acomplish this. Thanks =) The user needs to populate txtAddr and hit btnGen. The function will then confirm txtAddr is equal to a variable. If it is equal, populate other 2 text fields (txtKey & txtDest) with predefined variables. <form action="frmGen" method="post"> <input name="txtAddr" type="text"> <!-- User enters text here -- Confirm txtAddr.text = $VarAddr -- If True, continue. If False, display DIV message --> <input name="txtDest" type="text"> <!-- Text field is filled with value from server/SQL when btnGen is pressed--> <input name="txtKey" type="text"> <!-- Text field is filled with value from server/SQL when btnGen is pressed--> <input name="btnGen" type="button"> <!-- assuming txtAddr is True, display strings in 2 text fields above & store all values from 3 text boxes in SQL --> </form>
-
Hi everyone. I have another question, which will hopefully be the last piece to get my application going. I have a MySQL table with an enum field, with a few values (Value1, Value2, Value3, Value4). I have a HTML form that is pulling over fields from the same table, but those other fields are varchar fields. I'm wanting to create a drop down box which is dynamically populated with those enum values, and that defaults to the currently selected field. I have found a few examples of this, but they all seem to be deprecated mysql_* code, whereas I'm using mysqli_* throughout. I'm fairly new to PHP, and I have never written a function before. I figure something like this would be out there somewhere, but I haven't been able to find an example here at PHPFreaks, nor on various other forums. Here are some examples of what I have found using mysql_*: http://www.barattalo.it/2010/01/19/php-to-get-enum-set-values-from-mysql-field/ http://stackoverflow.com/questions/3715864/displaying-mysql-enum-values-in-php http://www.larryullman.com/forums/index.php?/topic/916-use-data-type-enum-for-form-drop-down-options/ http://www.pcserviceselectronics.co.uk/php-tips/enum.php I just don't know where to start with creating this function. I need to use this 3 times, or 2 different fields, which is why I assumed a function would be the best way to go. Thanks for any help!
-
I am trying to create a script (from a tutorial I try to adapt to my own needs) and I am running into a few problems. Here I go... I have an /includes folder which contains the following: database.php and functions.php with the following content: database.php <?php // Database connectivity stuff $host = "localhost"; // Hostname for the database. Usually localhost $username = "root"; // Username used to connect to the database $password = "root"; // Password for the username used to connect to the database $database = "blog"; // The database used // Connect to the database using mysqli_connect $connection = mysqli_connect($host, $username, $password, $database); // Check the connection for errors if (mysqli_connect_errno($connection)) { // Stop the whole page from loading if errors occur die("<br />Could not connect to the database. Please check the settings and try again.") . mysqli_connect_error() . mysqli_connect_errno(); } ?> functions.php <?php // Functions file for the system function show_posts($user_id) { $posts = array(); $sql = "SELECT body, stamp from posts where user_id = '$user_id' order by stamp desc"; $result = mysqli_query($connection, $sql); while ($data = mysqli_fetch_assoc($result)) { $posts = array( 'stamp' => $data->stamp, 'user_id' => $user_id, 'body' => $data->body ); } return $posts; } function show_users() { $users = array(); $sql = "SELECT id, username FROM users WHERE status = 'active' ORDER BY username"; $result = mysqli_query($connection, $sql); while ($data = mysqli_fetch_array($result)) { $users[$data->id] = $data->username; } return $users; } function following($user_id) { $users = array(); $sql = "SELECT DISTINCT user_id FROM following WHERE follower_id = $user_id"; $result = mysqli_query($connection, $sql); while ($data = mysqli_fetch_assoc($result)) { array_push($users, $data->user_id); } return $users; } ?> And here's the code that I run to display the users in users.php <?php $users = show_users(); foreach ($users as $key => $value) { echo $key . " " . $value; } ?> That throws me the following errors: Notice: Undefined variable: connection in /Applications/MAMP/htdocs/blog/includes/functions.php on line 22 Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /Applications/MAMP/htdocs/blog/includes/functions.php on line 22 Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /Applications/MAMP/htdocs/blog/includes/functions.php on line 24 I've tried to pass the $connection value to the show_users(); function with no results... any help would be appreciated. I am able to display the users from the database if I introduce the following code in users.php, but I want to try and keep things as clear as possible, without cluttering the files unnecessary. <?php $users = array(); $query = "SELECT id, username FROM users WHERE status = 'active' ORDER BY username"; $result = mysqli_query($connection, $query); if ($result) { while ($member = mysqli_fetch_assoc($result)) { echo strip_tags($member['username']) . "<br />"; } } else { echo "There are no posts to display. Why not add a new one?"; } mysqli_free_result($result); mysqli_close($connection); ?> PS: The users.php file also has require('includes/database.php'); and require('includes/functions.php'). I guess I'm trying to recreate the last bit of code into a working function... and I can't seem to do it. Any help is appreciated. I hope it makes an sense... -- Andrei
-
So this is my 2nd PHP class ever. And this right here is part of my final. I'm sure you all know what the "shuffle" function does. What I thought I could make it do was randomize a bunch of echoes I have. Is that possible? Any help would be greatly appreciated. KCCO! Here's the code I need tweaked: <html> <head> <title>Characters</title> <link rel="stylesheet" href="assets/css/bootstrap.css" media="screen"> <link rel="stylesheet" href="assets/css/bootstrap-responsive.css" media="screen"> <link rel="stylesheet" href="assets/css/normalize.css" type="text/css" media="screen"> <link rel="stylesheet" href="assets/css/style.css" media="screen"> </head> <body> <div class="navbar"> <div class="navbar-inner"> <a class="brand" href="#"></a> <ul class="nav"> <li class="active"><a href="Characters.php">Previous Clients</a></li> <li><a href="workForSupers.php">Work for Supers</a></li> </ul> </div> </div><!-- END of navbar--> <div align="center"> <h1>Supers we've helped locate</h1> <? date_default_timezone_set("America/Los_Angeles"); # set default timezone $imageDir = "images/"; # Comics is a PARENT class - Emily, Jenny, and so forth all are CHILDREN of Comics, meaning: They inherit the properties and methods included inside Comics. # For example: echo $joker->comiccharacters; will print out the $comiccharacters stored in Comics class Comics { const IMAGEDIR = "images/"; public $comiccharacters = "Comics"; } class Spiderman extends Comics { public $name = "Spiderman"; public $location = "New York City"; public $superpower = "his spider-sense, augmented speed and strength and his web shooters."; public $sex = "male"; public $published = "1963-03-01."; public $hero = true; public $asseskicked = 37; public $personscaught = [12,16,19,29,51]; public $powerlevel= '++++++'; public $email = "SpiderMan4Reals@gmail.com"; # A Constructor is automatically called when PHP is loaded public function __construct() { # set path for imageDir $this->imagePath = parent::IMAGEDIR . "spiderman.jpg"; } } $spiderman = new Spiderman(); class Magneto extends Comics { public $name = "Magneto"; public $location = "New York City."; public $superpower = "power of magnetism."; public $sex = "male"; public $published = "1963-10-15."; public $hero = false; public $asseskicked = 52; public $personscaught = [21,11,21,43,31]; public $powerlevel= '+++++++'; public $email = "ElMagneto@yahoo.com"; # A Constructor is automatically called when PHP is loaded public function __construct() { # set path for imageDir $this->imagePath = parent::IMAGEDIR . "magneto.jpg"; } } $magneto = new Magneto(); class Nightwing extends Comics { public $name = "Nightwing"; public $location = "Gotham City"; public $superpower = "is his peak physical conditioning, gadgets, and detective skills."; public $sex = "male"; public $published = "1985-01-06"; public $hero = true; public $asseskicked = 76; public $personscaught = [32,41,53,48,63]; public $powerlevel= '++++++'; public $email = "NightwingIsAwesome@hotmail.com"; # A Constructor is automatically called when PHP is loaded public function __construct() { # set path for imageDir $this->imagePath = parent::IMAGEDIR . "nightwing.jpg"; } } $nightwing = new Nightwing(); class GreenArrow extends Comics { public $name = "Green Arrow"; public $location = "Starling City"; public $superpower = "is his peak physical conditioning and accuracy with his gadgets."; public $sex = "male"; public $published = "1941-11-19"; public $hero = true; public $asseskicked = 62; public $personscaught = [17,17,29,31,49]; public $powerlevel= '++++++'; public $email = "ImTheGreenArrow@gmail.com"; # A Constructor is automatically called when PHP is loaded public function __construct() { # set path for imageDir $this->imagePath = parent::IMAGEDIR . "greenarrow.jpg"; } } $greenArrow = new GreenArrow(); class TheJoker extends Comics { public $name = "The Joker"; public $location = "Gotham City"; public $superpower = "being completely insane and psychotic."; public $sex = "male"; public $published = "1940-04-11"; public $hero = false; public $asseskicked = 112; public $personscaught = [61,79,103,94,52]; public $powerlevel= "++++++++"; public $email = "KillingForAJoke@gmail.com"; # A Constructor is automatically called when PHP is loaded public function __construct() { # set path for imageDir $this->imagePath = parent::IMAGEDIR . "joker.jpg"; } } $thejoker = new TheJoker(); # Create an array containing all the members classes $members = array($spiderman, $magneto, $nightwing, $greenArrow, $thejoker); # Calculate Ages - this cycles through all of the classes, and calculates the age for each band member, and places it in a property named "$age" foreach($members as $obj) { $obj->age = calculateAge($obj->published); } # Display our Jump Menu echo "<form name=\"jump\"> <p align=\"center\"> <select name=\"menu\" onchange='window.location.href=this.options[this.selectedIndex].value'> <option selected>All Characters</option> <option value=\"?sort=name\">Sort by Name</option> <option value=\"?sort=ageLoToHi\">Sort by Age (youngest to oldest)</option> <option value=\"?sort=ageHiToLo\">Sort by Age (oldest to youngest)</option> </select></p> </form>"; # Access the sort value from the url: blah.com/?sort=blam $sort = ''; if (isset($_GET['sort'])) { $sort = $_GET['sort']; } # Let's introduce all our members echo "<h2>Heroes and Villains Alike</h2>"; for ($i=0; $i < count($members); $i++) { switch ( $sort ) { # sort=name -- sorts alphabetically by 'name' in the member array case "name" : usort($members, 'sortByName_ascend'); displayProfile($members[$i]); break; case "nameRev" : usort($members, 'sortByName_descend'); displayProfile($members[$i]); break; # sort=ageLoToHi -- sorts alphabetically by 'age' ascending case "ageLoToHi" : usort($members, 'sortClassesByAgeLoHi'); displayProfile($members[$i]); break; # sort=ageHiToLo -- sorts alphabetically by 'age' descending case "ageHiToLo" : usort($members, 'sortClassesByAge_HiLo'); displayProfile($members[$i]); break; # sort=ageHiToLo -- sorts alphabetically by 'age' descending case "asseskicked" : uksort($members, 'sortAsseskicked'); displayProfile($members[$i]); break; # default -- spit out all band members according to their order in the array default : displayProfile($members[$i]); break; } } # This is a custom sorting function that works with usort(). # If you provide usort() with either an array or a set of objects, # it goes through all the items and compares them, and puts them in order # according to the rules below. function sortClassesByAgeLoHi($a, $b) { if ( $a->published == $b->published ) { #return 0; # this makes equivalent aged folks disappear return 1; } elseif ( $a->published > $b->published ) { return -1; } else { return 1; } } function sortClassesByAge_HiLo($a, $b) { return sortClassesByAgeLoHi($b, $a); # just reverse the arguments } function sortByName_ascend($a, $b) { if ( $a->name == $b->name ) { #return 0; # this makes equivalent aged folks disappear return 1; } elseif ( $a->name > $b->name ) { return 1; } else { return -1; } } function sortByName_descend($a, $b) { return sortByName_ascend($b, $a); # just reverse the arguments } # FUNCTIONS - Store all functions down here - I could also store them in another file function displayProfile($memberClass) { echo "<div class='memberProfile'><p>"; # spit out the image of our character # <img src="images/spiderman.jpg" /><br /> echo "<img src=\"".$memberClass->imagePath."\" width=200px /><br />"; #should make it so that when you refresh the page, it randomizes the order of the elements in the array shuffle($memberProfile); THE FOLLOWING IS SPECIFICALLY WHAT I WANT TO RANDOMIZE # spit out our caption echo "This is ".$memberClass->name.".<br>"; //counts the "+" for the power level echo "He has a power level of ".strlen($memberClass->powerlevel)." <br> "; echo "He resides in ".$memberClass->location.". <br>"; echo "He was first published in ".displayBirthdate($memberClass->published).".<br>"; echo "Making him ".calculateAge($memberClass->published)." years old! <br>"; //wraps the string after the specified # of characters echo "His superpower is ".wordwrap($memberClass->superpower,35,"<br>\n")."<br>"; echo "And in that time he's kicked the asses of ".$memberClass->asseskicked." people! <br>"; //finds the average & wraps the string after the specified # of characters echo "They normally capture their respective enemy ".average($memberClass->personscaught)." times a year.<br>"; echo "You can reach them at <a href=\"#\"> ".$memberClass->email.".</a>. <br> </p></div> "; } function displayBirthdate($bandmateBirthdate) { # January 1, 1984 $birthDateFormatted = date('F j, Y', strtotime($bandmateBirthdate)); return $birthDateFormatted; } function calculateAge($bandmateBirthdate) { #$currentTime = time(); # as a Unix timestamp list($year, $month, $day) = explode("-",$bandmateBirthdate); $elapsedYears = date('Y') - $year; $age = $elapsedYears; # calculates number of years elapsed # If current date < birthdate (i.e. Oct01 < Dec01), then subtract 1 year if ( date('n') < $month || ( date('n') == $month && date('j') < $day ) ) { $age = $age - 1; } return $age; } //example how to get the average in an array function average($average) { if (!is_array($average)) return false; return array_sum($average)/count($average); } ?> </body> <script type="text/javascript" src="js/bootstrap.js"></script> </html> Characters.php
-
Hi guys, I am trying to understand these questions regarding function and how or where can i get some knowledge to understand and create the code. questions are: 1. Open the text file “status.txt” as read only using variable $handle to store the file handle. 2. Begin a session. (what does it mean begin session? does it mean start using the if condition?) 3. Return the number of elements in array $days. 4. Convert an array $data with five elements into a string that is delimited by tab. (what does it mean by delimited by tab?) 5. Check if the form text item "status" obtained via get method is empty. Thank you in advance!
-
hey guys, so i am messing around with some simple JS, and i was using the onLoad & onUnload handlers. i can easily get the onLoad=(function) to work properly, yet when it comes to getting the onUnload to work when i close the window or refresh the site, noting seems to work <script> function alert1(){ alert("Welcome to the page, enjoy"); } function aler02(){ alert("Thanks for visiting, goodbye"); } </script> <body onLoad="alert01();" onUnload="alert02();"> <p> This is text </p> </body> again when i open the site, it works just fine and as expected. when i close or refresh i expect an alert to let me know i am leaving, yet nothing. any suggestions ?
- 4 replies
-
- javascript
- event handler
-
(and 1 more)
Tagged with:
-
I need help with performance improvement of this script. Script is working fine, but it's quite slow. It loads a lot of data, around 200.000. I am using paging to speed it up, but it's still slow. Can you give me any guide lines how to speed it up or to optimize? //Početak paginga if (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 1; } // if $upit11 = mysql_query("SELECT id FROM kalkulacija_stavke WHERE id_kalkulacija = '$id_kalkulacije' AND kataloski_broj NOT LIKE '1%'") or die (mysql_error()); $brojcanik = mysql_num_rows($upit11); $rows_per_page = 100; $lastpage = ceil($brojcanik/$rows_per_page); $pageno = (int)$pageno; if ($pageno > $lastpage) { $pageno = $lastpage; } // if if ($pageno < 1) { $pageno = 1; } // if $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page; mysql_query( "SET NAMES utf8", $veza ); mysql_query( "SET CHARACTER SET utf8", $veza ); if($_SESSION["checked"] = "checked"){ $upit = "SELECT kalkulacija_stavke.*, kalkulacija_zamjene_staro.ne_koristi_se FROM kalkulacija_stavke LEFT JOIN kalkulacija_zamjene_staro ON kalkulacija_stavke.kataloski_broj = kalkulacija_zamjene_staro.kataloski_broj_stari WHERE id_kalkulacija = '$id_kalkulacije' AND ne_koristi_se = '0' AND kataloski_broj NOT LIKE '1%' ORDER BY kataloski_broj ASC $limit"; } else { $upit = "SELECT * FROM kalkulacija_stavke WHERE id_kalkulacija = '$id_kalkulacije' AND kataloski_broj NOT LIKE '1%' ORDER BY kataloski_broj ASC $limit"; } $rezultat = mysql_query($upit,$veza) or die (mysql_error()); while($row = mysql_fetch_array($rezultat)){ $broj = $row["id"]; $id_kalk = $row["id_kalkulacija"]; $id_cjen = $row["id_cjenika"]; $vrijeme = $row["vrijeme"]; $kataloski_broj = trim($row["kataloski_broj"]); $kategorija_artikla = $row["kategorija_artikla"]; $grupa_proizvoda = $row["grupa_proizvoda"]; $podgrupa_proizvoda = $row["podgrupa_proizvoda"]; $cijena_eurska = number_format(round(($row["cijena_EUR"]),2),2,",","."); $cijena_KN = number_format(round(($row["cijena_KN"]),2),2,",","."); $carina = number_format(round(($row["carina"]),2),2,",","."); $spediter = number_format(round(($row["spediter"]),2),2,",","."); $banka = number_format(round(($row["banka"]),2),2,",","."); $transport = number_format(round(($row["transport"]),2),2,",","."); $nabavna_cijena = number_format(round(($row["nabavna_cijena"]),2),2,",","."); $drezga_marza_po_grupi = number_format(round(($row["drezga_marza_po_grupi"]),2),2,",","."); $drezga_zarada = number_format(round(($row["drezga_zarada"]),2),2,",","."); $neto_VPC = number_format(round(($row["neto_VPC"]),2),2,",","."); $neto_MPC = number_format(round(($row["neto_MPC"]),2),2,",","."); $trosak_firme = number_format(round(($row["trosak_firme"]),2),2,",","."); $trosak_firme_p = number_format(round(($row["trosak_firme_p"]),2),2,",","."); $diler_marza_po_grupi = number_format(round(($row["diler_marza_po_grupi"]),2),2,",","."); $preporucena_VPC = number_format(round(($row["preporucena_VPC"]),2),2,",","."); $preporucena_MPC = number_format(round(($row["preporucena_MPC"]),2),2,",","."); $zarada_diler_kn = number_format(round(($row["zarada_diler_kn"]),2),2,",","."); $zarada_diler_p = number_format(round(($row["zarada_diler_post"]),2),2,",","."); $zarada_za_nas_kn = number_format(round(($row["zarada_za_nas_kn"]),2),2,",","."); $zarada_za_nas_p = number_format(round(($row["zarada_za_nas_post"]),2),2,",","."); $brutto_zarada_za_nas_kn = number_format(round(($row["brutto_zarada_za_nas_kn"]),2),2,",","."); $brutto_zarada_za_nas_p = number_format(round(($row["brutto_zarada_za_nas_post"]),2),2,",","."); $datum1 = date("d.m.Y H:i:s",strtotime($vrijeme)); //Dohvačanje starih i zamjenjenih brojeva $upit23 = "SELECT ne_koristi_se, kataloski_broj_novi FROM kalkulacija_zamjene_staro WHERE kataloski_broj_stari = '$kataloski_broj'"; $query23 = mysql_query($upit23) or die (mysql_error()); $row = mysql_fetch_array($query23); $staro = $row["ne_koristi_se"]; $zamjena_novo = $row["kataloski_broj_novi"]; echo ' <tr> <td width="65"> '; if (!empty($zamjena_novo)){ echo '<img src="images/zamjena.png" border="0" title="Broj je zamijenjen sa '.$zamjena_novo.'">'; } if (!empty($staro) AND $staro == 1){ echo ' <img src="images/staro.png" border="0" title="Broj se ne koristi!">'; } //Dohvačanje naziva artikla iz NAV-a $upit233 = "SELECT naziv_artikla FROM kalkulacija_import_kategorija WHERE kat_br = '$kataloski_broj'"; $query233 = mysql_query($upit233) or die (mysql_error()); $row = mysql_fetch_array($query233); $naziv_artikla = $row["naziv_artikla"]; if (empty($naziv_artikla)) { $upit234 = "SELECT naziv FROM kalkulacija_import_cjenik_stavke WHERE kataloski_broj = '$kataloski_broj'"; $query234 = mysql_query($upit234) or die (mysql_error()); $row44 = mysql_fetch_array($query234); $naziv_artikla = $row44["naziv"]; } //Zamjena hrvatskih znakova $some_special_chars = array("æ", "è", "í", "ó", "ú", "Á", "É", "Í", "Ó", "Ú", "ñ", "Ñ"); $replacement_chars = array("ć", "č", "i", "o", "u", "A", "Ć", "I", "O", "U", "n", "N"); $replaced_string = str_replace($some_special_chars, $replacement_chars, $naziv_artikla); echo' </td> <td width="120"><span title="VPC: '.$neto_VPC.' - PVPC: '.$preporucena_VPC.'">'.$kataloski_broj.'</span></td> <td width="200">'.$replaced_string.'</td> <td width="100"><div align="center">'.$kategorija_artikla.'</div></td> <td width="110"><div align="center">'.$grupa_proizvoda.'</div></td> <td width="140"><div align="center">'.$podgrupa_proizvoda.'</div></td> <td width="110"><div align="center">'.$cijena_eurska.'</div></td> <td width="90"><div align="center">'.$cijena_KN.'</div></td> <td width="80"><div align="center">'.$carina.'</div></td> <td width="80"><div align="center">'.$spediter.'</div></td> <td width="100"><div align="center">'.$banka.'</div></td> <td width="80"><div align="center">'.$transport.'</div></td> <td width="100"><div align="center">'.$nabavna_cijena.'</div></td> <td width="80"><div align="center">'.$drezga_marza_po_grupi.' %</div></td> <td width="100"><div align="center">'.$drezga_zarada.'</div></td> <td width="90"><div align="center"><strong>'.$neto_VPC.'</strong></div></td> <td width="90"><div align="center"><strong>'.$neto_MPC.'</strong></div></td> <td width="90"><div align="center">'.$diler_marza_po_grupi.' %</div></td> <td width="100"><div align="center">'.$zarada_diler_kn.'</div></td> <td width="110"><div align="center"><strong>'.$preporucena_VPC.'</strong></div></td> <td width="110"><div align="center"><strong>'.$preporucena_MPC.'</strong></div></td> <td width="90"><div align="center">'.$brutto_zarada_za_nas_kn.'</div></td> <td width="90"><div align="center">'.$brutto_zarada_za_nas_p.'</div></td> <td width="80"><div align="center">'.$trosak_firme_p.' %</div></td> <td width="80"><div align="center">'.$trosak_firme.'</div></td> <td width="100"><div align="center">'.$zarada_za_nas_kn.'</div></td> <td width="80"><div align="center">'.$zarada_za_nas_p.'</div></td> <td width="150"><div align="center"> '; if ($status == 1) { echo '<a href="povjest_redak_kalkulacije.php?id='.$broj.'&id_kalkulacije='.$id_kalkulacije.'&kataloski_broj='.$kataloski_broj.'&id_cjenika='.$id_cjen.'"><img src="images/povjest.png" border="0" width="20" height="20" alt="Povijest" title="Pogledaj povjest artikla"></a> <a href="usporedba_redak_kalkulacije.php?id='.$broj.'&id_kalkulacije='.$id_kalkulacije.'&kataloski_broj='.$kataloski_broj.'&id_cjenika='.$id_cjen.'"><img src="images/history1.png" border="0" alt="Usporedba" title="Usporedba retka sa prošlom godinom" width="25" heigth="25"></a> <a href="calculator.php?id='.$broj.'&id_kalkulacije='.$id_kalkulacije.'" onclick="basicPopup(this.href);return false"><img src="images/calculator_n.png" border="0" title="Kalkulator zarade za dilera"></a></div></td>'; } else { echo'<a href="izmjeni_redak_kalkulacije.php?id='.$broj.'&id_kalkulacije='.$id_kalkulacije.'&id_cjenika='.$id_cjen.'"><img src="images/izmjeni.png" border="0" alt="Izmjeni" title="Izmjeni redak kalkulacije"></a> <a href="obrisi_redak_kalkulacije.php?id='.$broj.'&id_kalkulacije='.$id_kalkulacije.'&id_cjenika='.$id_cjen.'" onclick="provjera(this.href); return false;"><img src="../brisanje.png" border="0" alt="Obrisi" title="Obriši redak kalkulacije"></a> <a href="povjest_redak_kalkulacije.php?id='.$broj.'&id_kalkulacije='.$id_kalkulacije.'&kataloski_broj='.$kataloski_broj.'&id_cjenika='.$id_cjen.'"><img src="images/povjest.png" border="0" width="20" height="20" alt="Povijest" title="Pogledaj povjest artikla"></a> <a href="usporedba_redak_kalkulacije.php?id='.$broj.'&id_kalkulacije='.$id_kalkulacije.'&kataloski_broj='.$kataloski_broj.'&id_cjenika='.$id_cjen.'"><img src="images/history1.png" border="0" alt="Usporedba" title="Usporedba retka sa prošlom godinom" width="25" heigth="25"></a> <a href="calculator.php?id='.$broj.'&id_kalkulacije='.$id_kalkulacije.'" onclick="basicPopup(this.href);return false"><img src="images/calculator_n.png" border="0" title="Kalkulator zarade za dilera"></a></div></td> </tr> '; } } echo ' </table> <p align="center"> </p> <p align="center"> '; if ($pageno == 1) { echo " <font color='#990000'>Početak</font> || Natrag "; } else { echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1&id=$id_kalkulacije'>Prva</a> | "; $prevpage = $pageno-1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage&id=$id_kalkulacije'>Natrag</a> "; } // if echo " ( <font color='grey'>Stranica - <b>$pageno</b> od <b>$lastpage</b></font> ) "; if ($pageno == $lastpage) { echo " Naprijed || <font color='#990000'>Kraj</font> "; } else { $nextpage = $pageno+1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage&id=$id_kalkulacije'>Naprijed</a> | "; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage&id=$id_kalkulacije'>Posljednja</a> "; } // if echo " <br />Rezultata: ".$brojcanik." </p>";
-
Hi, I have a little snipplet I am posting here, I am not very experienced with PHP but thought I would ask some of you for help. I have to modify a program and a very small part of it is to remove lines where values are being set to blank or '' null values. Here is the little code snipplet: echo "\t\tfor(index=0; index < $maxclothrows; index++)\n"; echo "\t\t{\n"; echo "\t\t\tdocument.pickDivision.cloth.options[index].text = '';\n"; echo "\t\t\tdocument.pickDivision.cloth.options[index].value = '';\n"; echo "\t\t}\n\n"; This above code is used to set some values to ' ', but then after I would like those blank values removed rather then showing up in the list because when I scroll down you have a whole bunch of blank lines. How can I remove these completely? Maybe: echo "\t\t\if(document.pickDivision.cloth.options[index].text = '') {...some code here to remove this blank line} I read about regex or some str_replace, but am not sure how to use it. This program is around 3000 lines of code, so don't think I can attach the file. Any help would be greatly appreciated!
-
Hi All, A bit of a strange one here. I have created the below function and it works for the most part however I noticed that I was still getting access denied. I checked the httpd log and saw this error: [Tue Oct 01 10:12:46 2013] [error] [client 127.0.0.1] PHP Notice: Undefined index: $access in /var/www/xxxx/public_html/dev/v2.0/inc/functions.php on line 652 I then took a look at the MySQL log to see if there was an issue with the query that the function submits: SELECT grp.Can_View_Users, grp.group_id, group_name, group_enabled, grp.created, grp.updated FROM groups grp LEFT JOIN members AS users USING(group_id) WHERE users.id =27 GROUP BY grp.group_id as you can see here it is setting the parameter correctly but when setting it for the PHP code on line 652 it doesnt work :S confused. function GroupAccess($access){ $db = new DbConnector(); $db->connect(); $sql='SELECT grp.'.$access.', grp.group_id, group_name, group_enabled, grp.created, grp.updated ' .'FROM '.GROUP_TBL.' grp ' .'LEFT JOIN '.USER_TBL.' AS users USING(group_id) ' .'WHERE users.id ='.$_SESSION['uid'].' GROUP BY grp.group_id'; $result = $db->query($sql); $rows = $db->fetchArray($result); if($rows['$access'] == 1 && $rows['group_enabled'] == 1) return true; } the above starts at line 643 any assistance would be appreciated as im pulling my hair out here!!
- 6 replies
-
- undefined index
- php
-
(and 1 more)
Tagged with:
-
<!DOCTYPE html> <html> <head> <script> function HideComment() { document.GetElementById("comments").hide("textarea") } </script> </head> <body> <textarea name="" cols="" rows="" id="comments" onClick="">leave comment</textarea> </body> </html> i am trying to get the text area to hide when i click a button. this is what i have but doesnt seem to work. can someone help me?
- 8 replies
-
- javascript
- textarea
-
(and 2 more)
Tagged with:
-
In my DB class i have a function to do a simple sanitize operation. The function does three things: 1. checks weather the input variable is a integer, if it is then it gets the int value of the variable and returns it. 2. checks weather the input variable is a string, if it is then it escapes it and returns it. 3. if it is neither an integer or a string then the variable is unset and returns a "Variable deleted" message. function sanitizeData($dbc, $input){ if(is_int($input)){ $input = intval($input); return $input; } elseif(is_string($input)){ $input = mysqli_real_escape_string($dbc, $input); return $input; } elseif(!is_int($input) OR !is_string($input)){ unset($input); return "Variable contents unknown, variable deleted!"; } } I wanted other peoples ideas, opinions and suggestions on this function and what you think of it Thanks
-
When I type my Website URL It's all right. But When I press the sub-category to view the inner content then the problem is occur. There is 5 folder in my public_html.. They are: 1.admin 2.avatars 3.FTP 4.images 5.includes and some php files. This is a script. I can't php. ###There's some Error... Deprecated: Function ereg_replace() is deprecated in /home/exwggayd/public_html/includes/functions.php on line 62 Deprecated: Assigning the return value of new by reference is deprecated in /home/exwggayd/public_html/includes/phpflickr/phpFlickr.php on line 91 Deprecated: Assigning the return value of new by reference is deprecated in /home/exwggayd/public_html/includes/phpflickr/phpFlickr.php on line 330 Deprecated: Assigning the return value of new by reference is deprecated in /home/exwggayd/public_html/includes/phpflickr/phpFlickr.php on line 399 Deprecated: Assigning the return value of new by reference is deprecated in /home/exwggayd/public_html/includes/phpflickr/phpFlickr.php on line 468 Deprecated: Assigning the return value of new by reference is deprecated in /home/exwggayd/public_html/includes/phpflickr/PEAR/HTTP/Request.php on line 228 Deprecated: Assigning the return value of new by reference is deprecated in /home/exwggayd/public_html/includes/phpflickr/PEAR/HTTP/Request.php on line 324 Deprecated: Assigning the return value of new by reference is deprecated in /home/exwggayd/public_html/includes/phpflickr/PEAR/HTTP/Request.php on line 602 Deprecated: Assigning the return value of new by reference is deprecated in /home/exwggayd/public_html/includes/phpflickr/PEAR/HTTP/Request.php on line 621 Strict Standards: Redefining already defined constructor for class Net_URL in /home/exwggayd/public_html/includes/phpflickr/PEAR/Net/URL.php on line 122 Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/exwggayd/public_html/includes/phpflickr/PEAR/HTTP/Request.php on line 590 Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/exwggayd/public_html/includes/phpflickr/PEAR/HTTP/Request.php on line 591 Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /home/exwggayd/public_html/includes/phpflickr/PEAR/HTTP/Request.php on line 603 ##### The function.php inside the "includes" folder...may be there is the problem. But When I reload the page Everything Seems allright. Here is the Codes...Paste on Pastebin!! #function.php# hxxp://pastebin.com/PR4RKSJS #phpFlickr.php# hxxp://pastebin.com/zzaVehBx #Request.php# hxxp://pastebin.com/MPfq5zAL #URL.php# hxxp://pastebin.com/yDMvA7e5
- 1 reply
-
- ereg_replace()
- pereg_replace()
-
(and 3 more)
Tagged with:
-
Hi all I have problem with making custom function to deal with my scripts i tried and look on google but cant find here is code i have function errors() { $errors = array(); $_SESSION['errors'] = $key->$errors; foreach ($_SESSION['errors'] as $error) { return $error; } } and i use it like this in my script $error[] = 'Please enter username and password.'; but when i call function i have errors Notice: Undefined variable: key in C:\xampp\htdocs\core\_func.php on line 37 Notice: Trying to get property of non-object in C:\xampp\htdocs\core\_func.phpon line 37 Warning: Invalid argument supplied for foreach() inC:\xampp\htdocs\core\_func.php on line 38 please help me
-
I have been always questioning myself which should i use return or echo inside a fuction can somone clear this up for me . Thanks in advance. Audittxl
-
I wrote a long explaination, but then the page was refreshed an I lost it... essentially I can't get variables to work between functions, resorted to globals, I can get away with it, but I can't even get that to worl... code: <?php global $checkvar; //get the 'checkvar' this is an array of strings $checkvar = $_GET['checkvar']; checkvariable(); function checkvariable() { var_dump($checkvar); } ?> the dump of $checkvar comes up NULL in the function, but fine right after its been called.
-
Hi guys, It's a simple question really (just getting used to php - actionscript 3.0 developer!) but I need to know how I can pass a CSS class into the arguments in a PHP function, then have it apply that style to text in html. What I have so far is: <?php function addText($text,$class) { ?> <div class= $class > <p><?php echo $text ?></p> </div> <?php } ?> But it doesn't work, the <div class = $class > should be different I think. Anybody got a solution?
-
Trying to make a game where the user plays the computer, the user does not get to place ships and the computer does not try to sink the human's ships. on submit, the game is supposed to tell the user hit or miss or you sank my ship the board is supposed to remember where the user clicked each time until the game is over the computer randomly places 5 boats, I have the computer placing the boats, and I have some fire buttons, but its not connecting, and its not supposed to show where the boats are ( user is not supposed to see that part) <?php session_start() ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Battleship</title> <style type = "text/css"> #footer {font-size: small; text-align:center; clear:right; padding-bottom:20px; } body { background-image:url("infor.jpg"); color: white;text-align:center } p { color: yellow; text-align:center;} </style> </head> <body> <?php if(isset($_POST['start_game']) || isset($_POST['myGuess'])){ if (isset($_POST["counter"])){ $counter = $_POST["counter"]; } else { $counter = 0; } // end if $counter++; //store new data in counter $_SESSION["counter"] = $counter; if(isset($_POST['start_game']) || isset($_POST['myGuess'])){ if (isset($_POST["counter"])){ $counter = $_POST["counter"]; } else { $counter = 0; } // end if $counter++; //store new data in counter $_SESSION["counter"] = $counter; if(isset($_POST['choice'])){ if($_POST['choice']=="correct") print "<br>I got it! it took me $counter tries. <br>"; } $myGuess=rand($lowest,$highest); //This is used for debugging - keeping track of what each value is when the submit button is pressed // if(isset($_POST['choice'])){ //print_r($_POST); //} $form = "showOptions"; }else{ $form = "showStart"; } if($form == "showOptions"){ ?> <h2> <form method="post" action="" name="target"> <input type="Submit" value="Submit" align="MIDDLE"> </form> </h2> <form action="" method="post" > <table border="1" align="center"> <?PHP $step = $_POST['step']; if ($step > 2) { $step = 0; } else { $step += 1; }//end if if($step == 1) { for ($i = a; $i < k; $i++){ echo "<tr><td width='20' align='right'>$i</td>"; for ($j = 1; $j < 11; $j++){ echo "<td><input type='submit' value='fire' name='$i$j'></td>"; } // end for loop echo "</tr>"; } // end for loop echo "<tr><td></td>"; for ($j = 1; $j < 11; $j++){ echo "<td>$j</td>"; } echo "</tr></table>"; // result of fire } else { echo "Result "; for ($i = a; $i < k; $i++){ echo "<tr><td width='10' align='right'>$i</td>"; for ($j = 1; $j < 11; $j++){ echo "<td><input type='checkbox' checked='checked' disabled='disabled' name='$i$j'></td>"; } // end for loop echo "</tr>"; } // end for loop echo "<tr><td></td>"; for ($j = 1; $j < 11; $j++){ echo "<td>$j</td>"; } echo "</tr></table><br><input type='submit' name='' value='shoot'>"; }//end if ?> <input type="hidden" name="step" value="<?php echo "$step";?>" /> </form> </center> <?php if ($step == 0) { for ($i = a; $i < k; $i++){ echo "<tr><td width='10' align='right'>$i</td>"; for ($j = 1; $j < 11; $j++){ echo "<td><input type='submit' value='fire' name='$i$j'></td>"; } // end for loop echo "</tr>"; } // end for loop echo "<tr><td></td>"; for ($j = 1; $j < 11; $j++){ echo "<td>$j</td>"; } echo "</tr></table>"; //player fireing } else if($step == 1) { for ($i = a; $i < k; $i++){ echo "<tr><td width='10' align='right'>$i</td>"; for ($j = 1; $j < 11; $j++){ echo "<td><input type='submit' value='fire' name='$i$j'></td>"; } // end for loop echo "</tr>"; } // end for loop echo "<tr><td></td>"; for ($j = 1; $j < 11; $j++){ echo "<td>$j</td>"; } echo "</tr></table>"; // result of fire } else { echo "Result "; for ($i = a; $i < k; $i++){ echo "<tr><td width='10' align='right'>$i</td>"; for ($j = 1; $j < 11; $j++){ echo "<td><input type='checkbox' checked='checked' disabled='disabled' name='$i$j'></td>"; } // end for loop echo "</tr>"; } // end for loop echo "<tr><td></td>"; for ($j = 1; $j < 11; $j++){ echo "<td>$j</td>"; } } echo "</tr></table><br><input type='submit' name='' value='shoot'>"; }//end if ?> <input type="hidden" name="step" value="<?php echo "$step";?>" /> <h2>The number of squares for each ship is determined by the type of the ship. <BR /> The ships cannot overlap (i.e., only one ship can occupy any given square in the grid). <BR /> In each round, the Human clicks the target square which is to be shot at. <BR /> The Computer announces whether or not the square is occupied by a ship, <BR /> and if it is a hit they mark this on their own primary grid. <BR /> When all of the squares of a ship have been hit, the ship is sunk, <BR /> and the Computer owner announces this (e.g. You sunk my battleship!!). <BR /> If all of a player's ships have been sunk, the game is over and their opponent wins. </h2> <h2><?php echo "<br> <a href='battleshipmajorstart.php'>Reset Game</a>" ?></h2> <?php error_reporting( E_ALL ); // $ships['Ship Name'] = size (int); $ships = array( 'Carrier' => 5, 'Battleship' => 4, 'Destroyer' => 3, 'Submarine' => 3, 'Patrol Boat' => 2 ); // $grid[x-coord][y-coord] $grid = array(); // Loop through ships for placement foreach( $ships as $name => $size ) { // Begin an infinite loop ( dangerous, but we can break it when // the ship is happily placed ) while ( TRUE ) { // Determine direction of ship // x- horizontal, y- vertical $axis = ( mt_rand(0,1) == 1 ? 'x' : 'y' ); // Maximum values on grid $max = array( 'x' => 10, 'y' => 10 ); // Subtract $size from the max value to compensate for ship size $max[ $axis ] -= $size; // Generate random placement $x = mt_rand( 1, $max['x'] ); $y = mt_rand( 1, $max['y'] ); // Check to see if the grid is empty by checking $size squares in $axis direction for ( $i = 0; $i < $size; $i++ ) { //Create a temporary holder for our coordinates $curr = array( 'x' => $x, 'y' => $y ); ////Add current grid position to the direction we're going $curr[ $axis ] += $i; // Check to see if the grids populated if ( isset( $grid[ $curr['x'] ][ $curr['y'] ] ) ) //If it is, start at the beginning of the while loop and find new coordinates continue 2; } // If the for loop didn't run into a collision, then we know the grid space is empty //and we can break out of the infinite loop! break; } //Now that we have a position for the ship, write it into the grid! for ( $i = 0; $i < $size; $i++ ) { // Create a temporary holder for our coordinates $curr = array( 'x' => $x, 'y' => $y ); // Add current grid position to the direction we're going $curr[ $axis ] += $i; // Add the first letter of the ships name to the grid ( just for example purposes ) $grid[ $curr['x'] ][ $curr['y'] ] = substr( $name, 0, 1 ); } } //Display the grid echo '<table width="300" height="300" border="1" align="center">'; for ( $row = 1; $row <= 10; $row++ ) { echo '<tr>'; for( $col = 1; $col <= 10; $col++ ) { echo '<td width="30" align="center">'; echo ( isset($grid[$row][$col]) ? $grid[$row][$col] : ' ' ); echo '</td>'; } echo '</tr>'; } echo '</table>'; ?> <?php } else{ ?> When play begins, The Computer secretly arranges Her ships on Her primary grid. <BR /> Each ship occupies a number of consecutive squares on the grid, <BR />arranged either horizontally or vertically. <BR /> <BR /> The number of squares for each ship is determined by the type of the ship. <BR /> The ships cannot overlap (i.e., only one ship can occupy any given square in the grid). <BR /> In each round, the Human clicks the target square which is to be shot at. <BR /> The Computer announces whether or not the square is occupied by a ship, <BR /> and if it is a "hit" they mark this on their own primary grid. <BR /> The attacking player notes the hit or miss on their own "tracking" grid, in order to build up a picture of the opponent's fleet. <BR /> When all of the squares of a ship have been hit, the ship is sunk, <BR /> and the ship's owner announces this (e.g. "You sunk my battleship!"). <BR /> If all of a player's ships have been sunk, the game is over and their opponent wins. <form method="post" action="" name="choice"> <input name="start_game" id="start_game" value="Start Game" type="submit" src="game.png" name="image" width="100" height="150"><br> </form> <?php } ?> <p id="footer">Copyright © 2013 DeAnna Riddlespur & Gene Lau & Matthew Semple</p> </body> </html>
-
I recently filled out a job application for a web developer position. In addition to the usual 'tell us about yourself' questions, I was presented with this one. After searching the web and hacking at it for nearly an hour. I just punched in 5. I'm sure it's wrong. Anyway, I was wondering if someone could give me some clarification on what is happening here: <?php /* What value should you replace the '?' with to make the output read 10? */ var x = 6; var y = 4; var a = function(b) { return function© { return y + b + c; } }; x = 2; y = 5; var fn = a(x); x = 1; y = 3; var unknown = ?; console.log(fn(unknown));* ?> Am I reading correctly that the value of var a is equal to the value returned by function(b) which is equal to the value returned by function© which is y + b + c? I concluded that the value of var a = 4 + 2b + 2c. But since var b and var c are not defined how would I go about getting a strictly numeric value as output? Pardon my ignorance, but I have faced questions like this for other job apps and I am tired of staring at the screen like an idiot! Any clarification would be greatly appreciated!
-
I have a simple function public function showtrips($id,$table){ $sql="SELECT * FROM $table WHERE id = :id ORDER BY id DESC"; if(!$stmt = $this->conn->prepare($sql)){ // prepare failed echo "<pre>Prepare failed:\n"; print_r($pdo->errorInfo()); echo "</pre>"; } else { if(!$stmt->execute(array(':id'=>$id))){ // execute failed echo "<pre>Execute failed:\n"; print_r($stmt->errorInfo()); echo "</pre>"; } else { while($r = $stmt->fetch(PDO::FETCH_ASSOC)){ $data[]=$r; } return $data; } } } and a for loop that calls this function foreach($obj->showtrips($id,"trips") as $value){ extract($value); echo <<<show <tr class="success"> <td>$departTime</td> <td>$departPlace</td> <td>$arriveTime</td> <td>$arrivePlace</td> <td>$numberOfPass</td> <td>$purpose</td> <td>$cargo</td> <td>$remarks</td> </tr> show; } In my foreach loop how can I first test if the return variable $data has any data in it?
-
Ok so I am trying to make it so that I have the option to make my site display one of two pages. Maintenance.php if I put the site down, and Index.php for the default site. Here is my code so far but I am unsure as to why it does not work?? Maintenance.php <?php function maintenance($mode){ if($mode = TRUE){ echo '<META HTTP-EQUIV="Refresh" Content="0; URL=maintenance.php">'; exit; } else { echo '<META HTTP-EQUIV="Refresh" Content="0; URL=index.php">'; exit; } } ?> Under maintenance Index.php <?php require_once('maintenance.php') maintenance($mode = TRUE); ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Home</title> <link rel="stylesheet" type="text/css" href="css/style.css"> <link rel="SHORTCUT ICON" href="favicon.ico"> </head> Not under maintenance What seems to be the problem??
- 1 reply
-
- function
- maintenance
-
(and 1 more)
Tagged with:
-
I have 4 functions which are changing four different parameters. But when i change them one after another every parameter is changing without including 3 left. How can i change that? Here is the code: <script text="text/javascript"> $(function(){ $('#T1Slider').slider({ change: function(){ var T1 = $(this).slider('option','value') $('#lissajousOutput').attr('src', 'lissajous.php?T1='+T1) } }); }); </script> <script text="text/javascript"> $(function(){ $('#T2Slider').slider({ change: function(){ var T2 = $(this).slider('option','value') $('#lissajousOutput').attr('src', 'lissajous.php?T2='+T2) } }); }); </script> <script text="text/javascript"> $(function(){ $('#a1Slider').slider({ change: function(){ var a1 = $(this).slider('option','value') $('#lissajousOutput').attr('src', 'lissajous.php?a1='+a1) } }); }); </script> <script text="text/javascript"> $(function(){ $('#a2Slider').slider({ change: function(){ var a2 = $(this).slider('option','value') $('#lissajousOutput').attr('src', 'lissajous.php?a2='+a2) } }); }); </script> <link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> </head> <center><img src="lissajous.php" id="lissajousOutput"></center> </br></br> <center>T1<div name="T1" style="width: 800px; " id="T1Slider"></div></center> <br> <center>T2<div name="T2" style="width: 800px; " id="T2Slider"></div></center> <br> <center>a1<div name="a1" style="width: 800px; " id="a1Slider"></div></center> <br> <center>a2<div name="a2" style="width: 800px; " id="a2Slider"></div></center>
-
What is difference between require_once(), require(), include(). all the three function usely use to call a file in another file. what is the basic difference?
- 2 replies
-
- differnce
- reqire_once()
-
(and 3 more)
Tagged with:
-
Hey:) I have a question. It may sound dumb, but I can't figure out the problem. What I have: <html><body> <?php $x=5; $z=6; $y=$x+$z; function myTest() { global $x, $z, $y; echo $x . " " . $z . " " . $y . " "; $x++; $z++; } myTest(); myTest(); echo "<br>"; echo $x . " " . $z . " " . $y; ?> </body> </html> Now my problem is that I don't know why the value of y doesn't change. x and z are changing fine, but y isn't. Thanks:) Tim