umishra Posted April 7, 2009 Share Posted April 7, 2009 Hi, I wanted some help in foreach loop. The column values of a table in the DB are : Functional Performance Regression Smoke now,i want to read each of these values one by one. In an excel sheet,there is a column corresponding to the same table. I need to check that the column value in the excel should only contain the values "Functional Performance Regression Smoke". If it does not,then it should spit out an error. It should check each of the values in the excel file. Please help..................... Link to comment https://forums.phpfreaks.com/topic/152954-foreach-help/ Share on other sites More sharing options...
Yesideez Posted April 7, 2009 Share Posted April 7, 2009 Some sample data would be handy - not sure I understand what you're asking there... Link to comment https://forums.phpfreaks.com/topic/152954-foreach-help/#findComment-803296 Share on other sites More sharing options...
JasonLewis Posted April 7, 2009 Share Posted April 7, 2009 It's no use just asking for it either, put some effort in and give it a shot. Link to comment https://forums.phpfreaks.com/topic/152954-foreach-help/#findComment-803297 Share on other sites More sharing options...
umishra Posted April 7, 2009 Author Share Posted April 7, 2009 Some sample data would be handy - not sure I understand what you're asking there... Attaching the excel file that I want to check the values with. Here,Test Type column corresponds to the table named Test_Type. Now,in DB,table Test_Type contains the values Functional Performance Regression Smoke. I had written the code as $test_types = test_get_test_type( $project_id, $blank=true );//retrieves the values from DB foreach ($test_types as $tst_type) { echo "TST_TYP is $tst_type"; if (!empty($ts_type) && ($ts_type != $tst_type)) { echo "1"; error_report_show( $redirect_on_error, INCORRECT_TEST_TYPE_FILLED); } else { echo "&&&****&&&****"; } [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/152954-foreach-help/#findComment-803305 Share on other sites More sharing options...
Yesideez Posted April 7, 2009 Share Posted April 7, 2009 Contents of phphelp.txt: Test Type Performance Perf1 Functional Sm11 Test11 I still have no idea what you're asking - sorry! Link to comment https://forums.phpfreaks.com/topic/152954-foreach-help/#findComment-803312 Share on other sites More sharing options...
umishra Posted April 7, 2009 Author Share Posted April 7, 2009 Contents of phphelp.txt: Test Type Performance Perf1 Functional Sm11 Test11 I still have no idea what you're asking - sorry! Sorry,to not get it across to you. I mean that I want to upload this text file.Before that I need to check if the values mentioned in this txt file match the values in the Database. And the values contained in the Database are Functional Performance Regression Smoke. Since,this text file contains values like Perf1,Sm11 and Test11,uploading this file should fail. $test_types = test_get_test_type( $project_id, $blank=true );//retrieves the values from DB foreach ($test_types as $tst_type) { echo "TST_TYP is $tst_type"; if (!empty($ts_type) && ($ts_type != $tst_type)) { echo "1"; error_report_show( $redirect_on_error, INCORRECT_TEST_TYPE_FILLED); } else { echo "&&&****&&&****"; } $ts_type is the variable used to represent the column name. $test_types will be an array containing the values as retrieved from the DB. So,I am using foreach to read each of the element in the array. And as soon as it comes across a value,not present in the DB,it should throw out an error. Do you get me? Link to comment https://forums.phpfreaks.com/topic/152954-foreach-help/#findComment-803322 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.