Jump to content

dungpt29

Members
  • Posts

    29
  • Joined

  • Last visited

Everything posted by dungpt29

  1. I have read carefully your PHP script. In my opinion, the solution used in the script is too bad and it cannot help you display product data as desired. Therefore, you are to develop a new one. Currently, I am not sure what exactly your structure of the grid is. Can you describe it more detailedly using a drawing? How many columns does it have? What is name of each column if existed? If so, I will be ready to help you work out another solution to display the product list on your webpage.
  2. Note that: x = exp(log(x)); So, 1/5 = 5-1 = exp(log(5-1)) = exp(-log(5)); The PHP code to solve the equation should be: $x = log(sqrt(5),exp(-log(5)));
  3. <script type="text/javascript" language="javascript"> //<![CDATA[ $(document).ready(function(){ $("#seGolfer").change(function(){ document.getElementById("frmGolfer").submit(); }); }); //]]> </script> I am sorry for forgetting putting JavaScript code in script tags
  4. Something like this: <form id="frmGolfer" name="frmGolfer" action="" method="post"> <select id="seGolfer" name="seGolfer" size="1"> <option value="golfer_1">Golfer 1</option> <option value="golfer_2">Golfer 2</option> <option value="golfer_3">Golfer 3</option> </select> </form> $(document).ready(function(){ $("#seGolfer").change(function(){ document.getElementById("frmGolfer").submit(); }); }); In your PHP page, switch...case syntax should be used to process the case of which golfer being selected, as follows: <?php $golfer = $_POST["seGolfer"]; switch ($golfer) { case 'golfer_1': // Code to process the case of golfer_1 being selected break; case 'golfer_2': // Code to process the case of golfer_2 being selected break; case 'golfer_3': // Code to process the case of golfer_3 being selected break; } ?>
  5. The best way to solve your problem is testing email address at client side using a JavaScript function as the following: function checkemail(emailStr) { var emailPat = /^([A-Za-z0-9]+[_\-\.]?[A-Za-z0-9]+)+\@([A-Za-z0-9]+[\-\.]?[A-Za-z0-9]+)+(\.[A-Za-z]+)$/; if (!emailPat.test(emailStr)) { return false; } return true; }
  6. requinix's hint is good but obviously it is not enough to solve your problem. That is because JavaScript is a case-sensitive programming language and the output string must be in its original format after processing and the replacement must be case-insensitive. This is also the most difficult obstacles needed to overcome. Here, I put forward some directions that can actualize an effective solution: Convert the input string to uppercase (or lowercase). Convert the keywords in the array to uppercase (or lowercase). Specify the position of the first occurrence of the converted keyword in the converted input string. Based on the located position, split the original string into two substrings (called s1 and s2) with the keyword used as separator. Clearly, it is not simple to use String.split to achieve this. Create a new input string using concat method: the input string = concat(s1, "NOPE", s2); The pseudo-code to describe the solution should be as the following: Loop through the keyword array while (possible to locate the position of the keyword) Split the input string into two substrings s1 and s2 using keyword as separator; the new input string = concat(s1, "NOPE", s2); end while End Loop The result string = the final input string; If you cannot write the effective code, I will be ready to help you further.
  7. I will work out a solution but I do not know if it is the best way to solve your problem. I think its only shortcoming is that it will make your code longer. First, you should edit your code in buynow.php so that when users click the link to navigate to your coupon code page, this link will submit the form containing data such as name, address, email, etc. This means that this link has the role as a button instead of a normal link. To achieve this, Javascript or JQuery is recommended. In your coupon code page, your get user data using $_POST as normal. For example: $address= $_POST["txtAddress"]; Next, you should complement the hidden fields to the form in your coupon code page that are specialized in containing user data temporarily. For example: <input type="hidden" id="hdAddress" name="hdAddress" value="<?php echo $address?>" /> You get the temporary user data when turning back to your buynow.php as the following: $hdAddress= $_POST["hdAddress"]; You repopulate user data in buynow.php as the following: <input type="text" name="txtAddress" id="txtAddress" size="100" maxlength="100" value="<?php echo $hdAddress?>"/>
  8. Thanks for your remarks. I am striving to write the neater code in the future. And I have a question for your solution. Assuming that the input string contains the negative numbers. For example: $string = "<214.27080, -204.88100, 2500.51300>"; Based on your code, I guess the output string will be: $newstring = "214/-205/2500"; Based on OP's requirement, the output string must be: $newstring = "214/-204/2500"; What do you think of this case, Psycho?
  9. Another solution to solve your problem could be as follows: $a1 = array(); $a2 = array(); $a3 = array(); // $txtInput contains your input data that is <214.27080, 204.10100, 2500.51300> $a1 = explode(",", $txtInput); $a1_length = count($a1); for ($i=0; $i < $a1_length; $i++) { $a2 = explode(".", trim($a1[$i])); array_push($a3, $a2[0]); array_pop($a2); array_pop($a2); } $str = implode("/",$a3); $str = trim($str, "<");
  10. Hi sparkynerd, Because you are new to PHP so I will work out a solution that is most suitable to you and is just based on your own code. First, you need to create a new text file named LED_Status.txt that is in the same folder containing your graphic.txt. This file, just as its name, is specialized in containing the status of your LED that is either ON or OFF. The initial status filled in file should be OFF. The code to solve your problem should be as the following: <?php ///////////////////////////////////////////////////////////////////////////////////////////// // Check of LED2 is set. If it is, then use it if (isset($_POST["LED2"])) { $LED2= $_POST["LED2"]; //echo "<b>$LED2</b>"; } else { //$LED2 =""; // Reading the data from text file $LED_Status_Temp = file_get_contents('LED_Status.txt'); $LED2 = $LED_Status_Temp; // $LED2 is assigned the current status of your LED } if ($LED2 == "ON") { // Set led2 ON by calling the Arduino using fopen $h = @fopen("http://192.168.5.21/?LED=T", "rb"); $image = "/Graphics/LED_red.bmp"; // set and write data to text file $fp = fopen('LED_Status.txt','w'); fwrite($fp,$LED2); // update current LED status } else if ($LED2 == "OFF") { // Set led2 OFF by calling the Arduino using fopen $h= @fopen("http://192.168.5.21/?LED=F", "rb"); $image = "/Graphics/LED_green.bmp"; // set and write data to text file $fp = fopen('LED_Status.txt','w'); fwrite($fp,$LED2); // update current LED status } ///////////////////////////////////////////////////////////////////////////////////////////// // set and write data to text file { $fp = fopen('graphic.txt','w'); fwrite($fp,$image); } ///////////////////////////////////////////////////////////////////////////////////////////// // Reading the data from text file $graphictemp = file_get_contents('graphic.txt'); $graphic = ($graphictemp); ?>
  11. I reckon the cause is that you have not processed the case of none of your buttons is pressed yet. In that case $LED2 is an empty string and thereby $image is not defined.
  12. SQL syntax: INSERT INTO table_name (column1,column2,column3,...)VALUES (value1,value2,value3,...); only allows inserting one record per time.
  13. You should replace your last loop with the following: foreach ($candy as $type => $specific) { if ($type == 'chocolate') { echo $specific . "<br />"; } else { echo $type . ' ' . $specific; } }
  14. Hi prolife, I guess that you are trying to save the formatted text from a text editor into your database. Then you want to display it on your webpage as plain text. You should try the following PHP function and it worked for me: <?php echo html_entity_decode("data pulled out from database")?>
  15. Try the following code: <input type="radio" name="colour" value="male" <?php if ($mal == "checked") { ?> checked <?php } ?> /> <input type="radio" name="colour" value="female" <?php if ($fem == "checked") { ?> checked <?php } ?>/>
  16. First, you should complement id property for buttons. For example: <button name="LED2" id="btnLED2ON" style="height: 1.8em; width: 10em; font-size: 16px;" value="ON" type="submit">Power On</button> <button name="LED2" id="btnLED2OFF" style="height: 1.8em; width: 10em; font-size: 16px;" value="OFF" type="submit">Power Off</button> Note that id must be unique to HTML elements. Next, you complement onLoad event for body tag as the following: <body onload="audio_onload();"> You add script tags to implement audio_onload() function using javascript or Jquery as the following: <script type="text/javascript" language="javascript"> function audio_onload() { <?php if ($LED2 == "ON") { ?> // Turn text color of Power On button into red document.getElementById("btnLED2ON").style.color = "red"; <?php } ?> } </script>
  17. Hi trq, I have been studying and building a website based on ZF1 for 4 months. I find that ZF1 library is larger and more suitable for the beginners than ZF2's one.
  18. I guess that your folder set-up for Zend library is wrong from the beginning. I still assume the path to php.exe is: C:\wamp\php You need create a new folder named includes for example. Its path will be: C:\wamp\php\includes You move your Zend library into includes folder. The path to this library will be: C:\wamp\php\includes\library You edit the value of Environment variable zend_tool_include_path and set it to the following value: C:\wamp\php\includes\library You also edit include_path in php.ini as the following: include_path = ".;C:\wamp\bin\php\includes"
  19. I am also building a website based on Zend Framework 1.12 (ZF) and I have installed ZF with xampp not WAMP as you do. But I still share my experience with you and hope it will help you install ZF successfully. Your include_path should be as the following: (\library truncated) include_path = ".;C:\wamp\bin\php\zendframwork1.12" Assuming the path to your file php.exe is: C:\wamp\php You must set a System variable named path as the following: C:\wamp\php. This variable will point to php.exe You must copy three following important files of Zend and paste them into the folder C:\wamp\php zf.bat zf.php zf.sh ​You must set a System variable named zend_tool_include_path. Its value should be C:\wamp\bin\php\zendframwork1.12\library. This variable will point to Zend library that has been installed. Maybe you need restart your windows. To test whether Zend is recognized, you run cmd.exe, moving to C:\ and typing: C:\> zf show version If you get the answer such as: Zend Framework Version: 1.12.0, that demonstrates ZF has been successfully installed.
  20. I am trying to build a website and encounter a problem. When zoom is set at 100%, the layout is displayed well. When I zoom in, of course the font size of characters will increase but the width of container tag does not increase correspondingly. This causes the layout to be displayed not as expected. How to fix this problem? Any help would be appreciated!
  21. For example, I have a stored procedure in MySQL database as the following: DELIMITER $$ DROP PROCEDURE IF EXISTS `mydb`.`sp_insert_newnumber` $$ CREATE PROCEDURE `mydb`.`sp_insert_newnumber` (IN v_innumber INTEGER, OUT v_outnumber INTEGER) BEGIN set v_outnumber = v_innumber; select v_innumber as in_number; END $$ DELIMITER ; The PHP function that retrieves the value of out parameter is as the following: public static function insertNewAcc($param1, &$param2) { $options = array(Zend_Db::AUTO_RECONNECT_ON_UNSERIALIZE => true) $params = array( 'host' => 'localhost', 'username' => 'username', 'password' => 'password', 'dbname' => 'mydb', 'options' => $options); $db = Zend_Db::factory('Pdo_Mysql', $params); $stmt = new Zend_Db_Statement_Pdo($db, "call sp_insert_newnumber(:v_innumber, @v_outnumber)"); $stmt->bindParam(":v_innumber", $param1, PDO::PARAM_INT); $stmt->execute(); $rows = $stmt->fetchAll(); // Get result set returned by stored procedure $stmt->closeCursor(); $stmt = $db->prepare('select @v_outnumber as out_number'); $stmt->execute(); $outnumberset = $stmt->fetchAll(); $param2 = $outnumberset[0]['out_number'];// Retrieve the value of v_outnumber $db->closeConnection(); return $rows; } Here I explain the code in detail: The reason why I use @v_outnumber that is a session variable in MySQL and is passed to the output parameter of stored procedure is that the value of session variable is maintained during the connection to database that currently is held by $db. So I have to execute the second query using $db to get the value of out parameter. As I know, not just as SQL Server, MySQL 5.5 does not still support the syntax as suggested by Kicken.
  22. Hi kicken, First, thank you very much for your help. I am sure that your solution will not work. It is understandable because you are not a web developer using Zend. I have found out the solution for this problem by myself. It is quite simple and it works fine. By the way, anyone who has the same problem can reply to me and I am ready to share my experience.
  23. Hi annaharris, I found out the solution for this problem by myself weeks ago. And it works fine. Thank you very much for your care, annaharris! By the way, anyone who has the same problem can reply to me and I am ready to share my experience.
  24. I am trying to build a website based on: 1) MySQL 5.5.27 2) PHP 5.4.7 3) Zend Framework 1.12.0 I am trying to write a function that gets value of out parameter from a stored procedure as the following: public static function insertNewAcc($param1,&$param2) { $options = array(Zend_Db::AUTO_RECONNECT_ON_UNSERIALIZE => true); $params = array( 'host' => 'localhost', 'username' => 'username', 'password' => 'password', 'dbname' => 'mydb', 'options' => $options); $db = Zend_Db::factory('Pdo_Mysql', $params); $stmt = new Zend_Db_Statement_Pdo($db,"call sp_insert_newnumber(:v_in_number, @v_out_number);"); $stmt->bindParam(":v_in_number", $param1, PDO::PARAM_INT); $stmt->execute(); $rows = $stmt->fetchAll(); $db->closeConnection(); return $rows; } What is code to get value of @v_out_number that is an out parameter? Note that I use Zend_Db_Adapter_Pdo_Mysql for my web application. Any help would be appreciated!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.