Jump to content

sniperscope

Members
  • Posts

    280
  • Joined

  • Last visited

Everything posted by sniperscope

  1. Dear Thorpe The php code was simple. I've tried usort, ksort, asort....etc None of them was worked.
  2. Hi. I have a multidimensional array and i need sort it by two different key. I've tried almost every sort function but no chance. Array ( [0] => Array ( [0] => 1 [id] => 1 [11] => this is test [main_txt] => this is test [12] => 943965420 [add_time] => 943965420 [13] => 1323356400 [add_date] => 1323356400 ) [1] => Array ( [0] => 3 [id] => 3 [11] => another test [main_txt] => another test [12] => 943965120 [add_time] => 943965120 [13] => 1323702000 [add_date] => 1323702000 ) [2] => Array ( [0] => 32 [id] => 32 [11] => oppss one more test [main_txt] => oppss one more test [12] => 943944900 [add_time] => 943944900 [13] => 1323702000 [add_date] => 1323702000 ) [3] => Array ( [0] => 5 [id] => 5 [11] => okay, this is last one. Seriously [main_txt] => okay, this is last one. Seriously [12] => 943937160 [add_time] => 943937160 [13] => 1323615600 [add_date] => 1323615600 ) ) I need sort by add_date(Newer to Older) first then add_time(Later to Earlier) later. I hope i made my self clear.
  3. Marvelous. It is working now. Thank you so much for help. Have a great day
  4. the issue is query grab data from TABLE_A but repeat same data number of TABLE_B For example: I have 5 records in TABLE_B and i want to get phpfreaks.com, amazon.com, google.com, yahoo.com data from TABLE_A This query brings me phpfreaks.com, amazon.com, google.com, yahoo.com 5 times All i want is get data from TABLE_A and find out which data has The Latest entry.
  5. I want to get all data from table_a but sort it by add_date field in table_b
  6. Dear thorpe I used SELECT * because i need all fields (There is about 34 fields in TABLE_A but there is only 2 fields in TABLE_B shop_id and add_date)
  7. Hi I have join problem again. :'( Lets say i have a TABLE_A and TABLE_B I want to get all data from TABLE_A but sort by TABLE_B I have and sql query but it returns all data from TABLE_A but repeat it number of TABLE_B I know there is a simple but i cannot see it (i didn't sleep more than 50 hours maybe because of that) My query is : SELECT * FROM shop s LEFT JOIN search_up ss ON s.id = ss.shop_id WHERE s.shop_region = 'kansai' AND s.publication = 'dsp' AND (s.shop_area = 'osaka') ORDER BY ss.add_date DESC LIMIT 0,5 Thanks for any help.
  8. God damn it I don't know what to say. I really felt shame on me. and felt like stupid. How come i forgot about it. I am trying to solve it about two days. Dear Teynon Thanks for reply. You show me that "No matter How many years building web pages, sometimes you may fail too like newbie"
  9. Hi Recently my web page stop for <a> tags. Current a tags are something like this index.php <a href="www.google.com">Google</a> <a href="yahoo.com">Yahoo</a> When clicking those links they loop inside my site. Like below www.mysite.com/index/yahoo.com or www.mysite.com/index/www.google.com What is wrong?
  10. Hi There is a page which i want to get contents from there. I want to get url and text (or entire A tag) from <a href="http://www.example.com/show.php?id=59176" class="most_read">»Some daily news</a><br> Regards
  11. I have something like below $j = explode("-", $ROW['options']); if(array_search("src_str", $j) == false) echo '_no'; // This doesn't work Also i tried $j = explode("-", $ROW['options']); if(!in_array("src_str", $j)) echo '_no'; // This also doesn't work Is this bug or am i doing something wrong?
  12. I solved. Hope this solution help someone else. $NEW_OPTION = array(); for($i=0; $i<count($OPTIONS); $i++) { $EXP = explode("-", $OPTIONS[$i]); for($j=0; $j<count($EXP); $j++) { $NEW_OPTION[] = $EXP[$j]; } } $DISPLAY_OPTIONS = array(array_count_values($NEW_OPTION));
  13. Hello I am facing a problem which i can not handle. I appreciate for any help. My Database is: CREATE TABLE IF NOT EXISTS `shops` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `options` text, `user_name` varchar(250) NOT NULL , PRIMARY KEY (`id`), UNIQUE KEY `user_name` (`user_name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='user data stored' AUTO_INCREMENT=1 ; And some sample data as below: INSERT INTO `users` (`id`, `options`, `user_name`) VALUES (1, 'apple-orange-grape-bmw-toyota-fig-', 'user1'), (4, 'apple-tomato-pc-notebook-yellow-', 'user2'), (5, 'blue-green-orange-cdrom-', 'user3'), (6, 'orange-yellow-blue-pink-bread-', 'user4'); How can i display how many apples or green or any item selected by user? So far i tried in_array, array_count_values but seems no one is working. Regards
  14. Problem solved. Here is solution. Hope this help someone else CONCAT(Firstname, Lastname, Middlename, Fathername) LIKE '%something_search_string%'
  15. Hi, I have a table which is holding person name as Firstname, Lastname, Middlename, Fathername But i have only one input area in my form. So, how can i search all those columns with a single text? I hope i made my self clear.
  16. Super fast and excellent answer. Thank you thorpe :
  17. Hello is there any function in mysql like substr() in php. Let's say i have a record something like ID, Name, Lastname, Birthday (100004, 'Username', 'Userlastname', '2002-10-03') and i want to search user who was born in October. Is this possible with mysql? Regards
  18. Thank you very much for your time and suggestion I really appreciate that. Regards. Let me check what is Foreign key it is... Have a nice day.
  19. Okay i just end up with a query something like select users.id, login_table.login_date, login_table.login_ip from users left join login_table on users.id = login_table.users_id AND login_table.login_date ='1316012400' is this query fair enough for 20.000 record?
  20. Hello Could someone tell me how can i merge tables has one-two-many relation. For example there is user table: CREATE TABLE IF NOT EXISTS `users` ( `id` int(4) unsigned NOT NULL auto_increment, `userName` varchar(30) collate utf8_unicode_ci NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; and some another table: CREATE TABLE IF NOT EXISTS `login_table` ( `id` int( unsigned NOT NULL auto_increment, `users_id` int(4) NOT NULL default '0', `login_date` int(10) NOT NULL default '0', `login_ip` int(20) NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=4210 ; I could not find a best solution so far. What i want is get all users from users table and ip address from login _table ONLY logged in (let's say)today. Because users log everyday when they logged in. Best Regard
  21. Dear Keith If you don't mind may i have an example Please
  22. Dear Fenway Thank you for your interest. After Googling for a while i came up with this query $QUERY = " SELECT * FROM `sdb`.`Student` s INNER JOIN addr a ON s.zipcode = a.zipcode INNER JOIN enrol en ON s.SID = en.SID INNER JOIN SCourse sc ON en.SCourseID = sc.SCourseID INNER JOIN course c ON sc.CourseID = c.CourseID INNER JOIN fenrol fe ON c.CourseID = fe.CourseID WHERE s.SName = '$SName' AND c.CourseID='$CourseID' AND sc.WeekDay='$WeekDay'"; My student table has one to many relation with course table Some student can get lesson twice or trice in a week and if i run query above then i got 3 records(if student takes tree course in a week) at same name, same address same age same group How can i distinct course (i just want to take only one course name. Student may take only one course in a week or takes 100 course in a week it doesn't matter) Lord... i am almost forgetting English. If my English hard to understand please tell me. Regards
  23. Hello i am writing a html form but i have problem with reading array. Here is html form: <tr style="background-color: rgb(254, 242, 99);"><td>dghhf <input name="id[]" value="<?php echo $row['id']" type="hidden"> <input name="dbcheck[]" value="IF_THERE_IS_RECORD_TYPE 1 OR TYPE 0" type="hidden"></td> <td align="center"><input name="chk1[]" checked="checked" type="checkbox">chk1 <input name="chk2[]" type="checkbox">chk2 <input name="chk3[]" type="checkbox">chk3</td> <td align="center"> <select name="StartHour[]"> <option value=""></option> <option value="00">00</option><option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05" selected="selected">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option> </select>:<select name="StartMin[]"><option value=""></option><option value="00">00</option> <option value="30" selected="selected">30</option></select> ~ <select name="EndHour[]"> <option value=""></option><option value="00">00</option><option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20" selected="selected">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option> </select>:<select name="StartMin[]"><option value=""></option><option value="00" selected="selected">00</option> <option value="30">30</option></select></td></tr> Above HTML works great and no problem however my php code always take first record. Here is php section: <?php $TODAY = strtotime($_GET['d']); if(isset($_POST['WorkEntry'])) { for($ii=0; $ii<count($_POST['girl_id']); $ii++) { if(isset($_POST['chk2'][$ii])){ $To = ""; $From = "ASK"; } else{ $To = $_POST['StartMin'][$ii]; $From = $_POST['StartHour'][$ii]; } if(isset($_POST['chk3'][$ii])) $ei = 1; else $ei = 0; if($_POST['dbcheck'][$ii] == 1) { echo $_POST['dbcheck'][$ii]; } else { if(isset($_POST['chk1'][$ii])) { $DELETE = "DELETE FROM time_table WHERE _id = '" .$_POST['_id'][$ii]. "' AND w_date = '" .$TODAY. "'"; } } echo $ei ."<BR>"; } } ?>
  24. I solved problem. The problem was variable name in javascript. So after correction variable name then it works. Hope this help someone else.
×
×
  • 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.