Jump to content

PriteshP23

Members
  • Posts

    79
  • Joined

  • Last visited

Everything posted by PriteshP23

  1. Hello, I have used Single Translation Table Approach to make multilanguage site in PHP. You may see here The current index page is not working. My objective is to have one example to use these tables and display one working page. For example: It should work like this by using those tables (app_language, app_product, app_translation, app_translation_entry). What i did so far on my home page: <!DOCTYPE html> <?php session_start(); $_SESSION['current_language'] = "fr"; $con = mysql_connect("localhost","worksite",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("worksite", $con); ?> <?php // handle language selection if(in_array($_GET['lang'], $languages)) { $_SESSION['lang'] = $_GET['lang']; } // define LANG constant only if it exists in $languages array, otherwise default to EN define('LANG', in_array($_SESSION['lang'], $languages) ? $_SESSION['lang'] : 'fr'); define('LANG', in_array($_SESSION['lang'], $languages) ? $_SESSION['lang'] : 'en'); // display language options foreach($languages as $language) { echo '<a href="?lang='.$language.'">'.$language.'</a>'; } $sql = "SELECT p.*, l.name as language_name, te.field_text as title FROM `app_product` p INNER JOIN `app_translation_entry` te ON p.title = te.translation_id INNER JOIN `app_language` l ON te.language_code = l.code WHERE p.id = 1"; if($result = mysql_query($sql)){ while($row = mysql_fetch_assoc($result)){ echo "Language (".$row["language_name"]."): ".$row["title"]."<br>"; } } // Retrieve appropriate title according to the chosen language in the system $sql = "SELECT p.*, l.name as language_name, te.field_text as title FROM `app_product` p INNER JOIN `app_translation_entry` te ON p.title = te.translation_id INNER JOIN `app_language` l ON te.language_code = l.code WHERE p.id = 1 AND te.language_code = '".$_SESSION['current_language']."'"; if($result = mysql_query($sql)){ if($row = mysql_fetch_assoc($result)){ echo "Current Language: ".$row["title"]; } } ?> </body> </html> You may edit this file as you wish but it should be working as per example link (demo). I want to build static website from above approach. Thanks in advanced for your time and input.
  2. @jazzman1 Your logic is right. I agree. But in my file it is was not working and difficult to mange (in terms of variables, whitespace problems). The earlier script worked, so i keep that in my file. I am very thankful to you for your help and time.
  3. Yes, this is working fine..! Thanks a lot
  4. It will be great if anyone can give input to check the filesize and if it is too big, make 4 parts instead of 3 parts. I did so far: head -1125000 cells_20140107_154016.xml > PART1.xml echo "</details></cells>" >> PART1.xml echo "<cells><details>" >> PART2.xml sed -n '1125001,2250000p' cells_20140107_154016.xml >> PART2.xml echo "</details></cells>" >> PART2.xml echo "<cells><details>" >> PART3.xml sed -n '2250001,3480000p' cells_20140107_154016.xml >> PART4.xml The main task is to make it in general. Expected output: head -1125000 filename.xml > PART1.xml echo "</details></cells>" >> PART1.xml echo "<cells><details>" >> PART2.xml sed -n '1125001,2250000p' filename.xml >> PART2.xml echo "</details></cells>" >> PART2.xml echo "<cells><details>" >> PART3.xml sed -n '2250001,3480000p' filename.xml >> PART4.xml I hope i am clear. Thanks in advanced for your time and input.
  5. Hello, I have one big XML file (600 MB - 850 MB) in format "cells_yyyymmdd_hhmi.xml" I would like to specify that everyday i will have new file with new date. So, there should be general way to rea For exmaple, i have file of 7th January. Its, cells_20140107_154016 Goal is to split into small parts by shell script and do operation.
  6. Finally, it works cd $file/path u=$(date +%u) if [ ${u} -eq 1 ] ; then dateQ=`date --date='-3 day' +'%Y%m%d'` else dateQ=`date --date='-1 day' +'%Y%m%d'` fi zcat my_file_"$dateQ"*.tar.Z | tar xvf - Thank you all for your time and input.
  7. Good try. I like it. But there is error: Wrong parameter count for explode() It is not expected as solution because everyday it will change the filename. In addition, i have to read filename with date and later display the time from it.
  8. Yes, you are right. This is the question. How to make it general so that it take the value which is in filename? There are no more files. So, no need to find latest date or deleting other files like that. Thanks in advanced for your input.
  9. Hello, I have csv filename with date. Everyday i have same csv file with respective date. I need to read filename (everyday date changes in filename) and do operation. For example, I have file "cells_20140106_165532.csv". I did like this to read it in general: $filename = "cells_".date('Ymd_hmi').".csv"; $file_contents = file_get_contents($filename); $importcsvsql = ""; It is taking current date instead of filename's date. It is generating empty file "cells_20140114_110109.csv" Thanks in advanced.
  10. Is it possible to write like this ? u=$(date +%u) if [ ${u} -eq 1 ] ; then dateQ=`date --date='-3 day' +'%Y%m%d'` else dateQ=`date --date='-1 day' +'%Y%m%d'` fi zcat my_file_"$dateQ"*.tar.Z | tar xvf - If possible, i would like to have link which provides shell script example with output. Thanks in advanced.
  11. To unzip, zcat is working fine: zcat $file | tar xvf - i need to correct the part of date in the script. dateQ='20[0-9]{2}(0[1-9]|1[0-2])([0-2][0-9]|3[0-1])' if [ ${u} -eq 1 ] ; then dateQ=`date --date='-3 day' +'%Y%m%d'` else dateQ=`date --date='-1 day' +'%Y%m%d'` fi I believe there are more options possible. In fact, my goal is to check the date of file. There are 7 files inside the .tar.Z file. With that 7 files i need to do update operation in my database. Normally, everyday (Monday to Friday) i will receive new file with respective date. I need to check the date and display the date of file. For example, if one day i have not received file in that case, i need to use previous file. Simple example: Day 1: 09 Jan 2014 I have received the .tar.Z file --> extract --> update operation --> Mesg "File has received 09 Jan 2014" Day 2: 10 Jan 2014 I have received the .tar.Z file --> extract --> update operation --> Mesg "File has received 10 Jan 2014" Note: DELETE FILE OF 9th Jan Day 3: 13 Jan 2014 I have NO Files. So, i have to use yesterdays file and repeat the same procedure with ALERT MESG. "File has received 10 Jan 2014" (in RED) There should be one file ALWAYS available to do update operation, no matter which date. I hope i am clear.
  12. I got file from Monday to Friday. I need to verify that it should not be delay of more than 3 days. My file name is difficult to handle in shell script and check the date. Files are like this --> my_file_20140103_1540.tar.Z (For Friday) / my_file_20140106_1460.tar.Z (For Monday) / my_file_20140107_1120.tar.Z (For Tuesday) For example, if its monday than it must be the date of Friday (maximum late), not the file with date of thursday. In addition, if its Wednesday, i need to check if it is date of Tuesday --> OK, it its date of Monday --> NOK I hope i am clear. not working We need to correct the dateQ logic. It should be modified in order to print the value of filename. I think here is file of 3rd January 2014 and it need to adjust with current time. May be that's why it is not giving output. I have already written my filename in the question. Anyway, i repeat the file is in tar.Z format " my_file_20140103_1540.tar.Z " .
  13. Hello, I have one "tar.Z" file. Objective is to unzip it by shell script and check the date. File archive: filename_20140103_1540.tar.Z #!/bin/bash cd $REP_DATAS/path u=$(date +%u) if [ ${u} -eq 1 ] ; then dateQ=`date --date='-3 day' +'%Y%m%d_%H%m'` else dateQ=`date --date='-1 day' +'%Y%m%d_%H%m'` fi tar xvf filename_"dateQ".tar.Z THANKS IN ADVANCED.
  14. #!/bin/sh DB_USER="****" DB_PASS="****" DB_NAME="****" echo "##########" echo $1 echo "##########" echo date cd customer for i in *-*.php do echo $i php $i $1 echo date I need something like this. This is just REFERENCE. It is not working.
  15. Well, I have already mentioned that "Things to do:" The problem is that i am looking for a shell script which can perform expected operation.
  16. Hello, I have one tar.Z file. I have to run shell script daily as it is required to update the database. customer_yyyymmdd_hhmi.tar.Z sales_ yyyymmdd_hhmi.csv (5 MB - 20 MB) purchase_ yyyymmdd_hhmi.xml (650 MB - 950 MB) I have made small part of XML file. There are 4 parts. There is PHP Script which is working but i need to change each time file like PART1.xml, PART2.xml etc. Things to do: 1) Extract tar.Z file and Read CSV and XML file. 2) Read whole XML file automatically. I hope i am clear. Thanks in advanced for your time and input.
  17. Thanks in advanced to give an example (if possible) of what you have said. I am sorry but i didn't get you. How it will work in my code ? I do not know how to apply your logic to get expected output.
  18. Problems: 1. IF we don't select Model; it gives message for both to select again. It should ask ONLY for model. 2. Input for Select All button 3. Input for Filename
  19. Hello, I would like to solve form problem. Here is my code: /************************** Step 1: Select Cell************************************/ if(isset($_POST['SmartPhone'])) $checked1=$_POST['SmartPhone']; $form->add_checkbox('SmartPhone','SmartPhone',$checked1); if(isset($_POST['Apple'])) $checked2=$_POST['Apple']; $form->add_checkbox('Apple','Apple',$checked2); /************************** Step 2: Select Model************************************/ if($_POST['SmartPhone']==false and $_POST['Apple']==false) { $this->add(new error('<span style="color:red">Select your cell..!!</span>')); $this->step1(); return; } if(isset($_POST['S4'])) $tech2=$_POST['S4']; $form->add_checkbox('S4','S4',$tech2); if(isset($_POST['iPhone 5'])) $tech3=$_POST['iPhone 5']; $form->add_checkbox('iPhone_5','iPhone 5',$tech3); if(isset($_POST['iPhone 5s'])) $tech1=$_POST['iPhone 5s']; $form->add_checkbox('iPhone_5s','iPhone 5s',$tech1); //In addition, i want to know how to put "Select All" button here // in order to SELECT ALL MODELs: S4, iPhone 5, iPhone_5s /************************** Step 3: File Generation************************************/ if($_POST['S4']==false and $_POST['iPhone_5']==false and $_POST['iPhone_5s']==false) { $this->add(new error('<span style="color:red">Please enter your model..!</span>')); $this->step2(); return; } $date = date('Y-m-d_H-i-s'); // Filename should be like this format "cell_datetime.xml" // For example: SmartPhone_20130910183023.xml or Apple_20130910183023.xml // Any idea how to create such filename?? Thanks for your time.
  20. I'm not sure I follow. I created new table "vtest" CREATE TABLE `vtest` AS SELECT * FROM `version` Then i tried to DELETE rows from the vtest table by this query: DELETE FROM `vtest` WHERE ( SELECT v.nidt, v.noeud, v.version, v.id FROM version v JOIN ( SELECT nidt, noeud, MAX(version) as maxversion FROM version GROUP BY nidt, noeud ) latest USING (nidt, noeud) LEFT JOIN ( SELECT nidt, noeud, MAX(version) as maxoper, 1 AS isoper FROM version WHERE etat_fonct = 'OPERATIONAL' GROUP BY nidt, noeud ) oper USING (nidt, noeud) WHERE (isoper AND ((etat_fonct<>'OPERATIONAL') OR (version < maxoper))) OR (isoper IS NULL AND version < maxversion) ) Error: #1241 - Operand should contain 1 column(s) or am I misinterpreting something? I am sorry but I did not get you. Can you give example, please? Thank you ALL in advanced for your TIME.
  21. In that case also i need to DELETE rows. How to manage this ? I would be greatful to you if we can SOLVED this.
  22. Well it is not expected at all CREATE TABLE IF NOT EXISTS `version` ( `id` int(11) NOT NULL auto_increment, `nidt` varchar(11) NOT NULL, `noeud` tinyint(3) NOT NULL, `VERSION` float NOT NULL, `ETAT_FONCT` varchar(20) default NULL, `idnap` varchar(25) NOT NULL, `nidtint` bigint(20) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=28546 ; SQL: DELETE FROM version WHERE version.id NOT IN (SELECT MAX(VERSION) FROM version WHERE `ETAT_FONCT` = 'OPERATIONAL' GROUP BY `noeud`,`nidt` HAVING MAX(VERSION) IS NOT NULL) #1093 - You can't specify target table 'version' for update in FROM clause :confused:
  23. @Guru: I did. Good remark. DELETE FROM version WHERE version NOT IN (SELECT MAX(VERSION) FROM version WHERE `ETAT_FONCT` = 'OPERATIONAL' GROUP BY ETAT_FONCT) #1093 - You can't specify target table 'version' for update in FROM clause Still NOT Working
  24. @vinny42: I have to delete rows in order to do next operations and generate xml file. With LEFT JOIN it seems difficult. It will be best if table has good rows that are needed to do next operations.
  25. @Guru: I have not taken all the data. Here it is sample for the test: CREATE TABLE IF NOT EXISTS `version` ( `nidt` varchar(11) NOT NULL, `noeud` tinyint(3) NOT NULL, `VERSION` float NOT NULL, `ETAT_FONCT` varchar(20) default NULL, `idnap` varchar(25) NOT NULL, `nidtint` bigint(20) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8; INSERT INTO `version` (`nidt`, `noeud`, `VERSION`, `ETAT_FONCT`, `idnap`, `nidtint`) VALUES ('00000001B2', 16, 10, 'OPERATIONAL', '1_00000001B2_712_e16', 1012016), ('00000001B2', 16, 11, 'NOT_OPERATIONAL', '1_00000001B2_113_e16', 1012016), ('00000001B2', 17, 11, 'NOT_OPERATIONAL', '1_00000001B2_113_e17', 1012017), ('00000001B2', 17, 10, 'OPERATIONAL', '1_00000001B2_712_e17', 1012017), ('00000001B2', 18, 10, 'NOT_OPERATIONAL', '1_00000001B2_712_e18', 1012018), ('00000001B2', 18, 11, 'OPERATIONAL', '1_00000001B2_113_e18', 1012018), ('00000001E1', 16, 9, 'NOT_OPERATIONAL', '1_00000001E1_313_e16', 1041016), ('00000001E1', 17, 9, 'NOT_OPERATIONAL', '1_00000001E1_313_e17', 1041017)) ('00000001E1', 18, 9, 'NOT_OPERATIONAL', '1_00000001E1_313_e18', 1041018), ('00000001F3', 16, 12, 'OPERATIONAL', '1_00000001F3_313_e16', 1053016), ('00000001F3', 16, 11, 'NOT_OPERATIONAL', '1_00000001F3_712_e16', 1053016)) I need to do more operations AFTER deleting these data and this is very urgent. Please help me to solve this problem.
×
×
  • 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.