
euel
Members-
Posts
42 -
Joined
-
Last visited
Never
Everything posted by euel
-
I see... Can you direct me to somewhere i can get more info ? Thanks for the reply!
-
Good Day! I'm trying to rework a page in my site and its seems i got stuck. I have a page with a generated table where each row has 2 select tags. I want to put a checkbox/radio button at the end of each row so the user can select all the data before submitting the form for processing. The problem is can't think of the code how to select all the data when a checkbox/radio button is checked. Sorry if my explantion is unclear, im confused ryt now... Thanks for the help!
-
ah, now it make sense to me.. thank you for pointing that simple thing to me! really appreciated.. tried it and worked.. now i just need to get what values goes to where.. >.< Thanks!!
-
Hi guys! I need your help.. I'm having a problem in getting the post values from my form, I have 2 arrays and some values: $total = 3; $array1 = (branch1, branch2, branch3); $array2 = (100, 200, 300); $count = count($array1) - $total; then i combine them $array3 = combine_array($array1, $array2); if $count is 0, using a foreach loop i echo each value and key foreach($combined_array as $value => $key) { echo "<tr>"; echo "<td><input type='hidden' name='branch' value='{$value}'></td>"; echo "<td id='edit'>" . "<input type='submit' name='edit' value='' />" . "</td>"; echo "<td id='sep'> / </td>"; echo "<td><input type='hidden' name='id' value='{$key}'></td>"; echo "<td id='del'>" . "<input type='submit' name='delete' value='' />" . "</td>"; very simple and it works perfectly fine, but if the variable $count is not equal to 0, i append both arrays(1 & 2) so that it will be equal to 0. (data appended is not important i just need them for the table output.) for($i = 0; $i < $count; $i++) { $array1[] = "null" . $i; $array2[] = $i; } // then combine $array3 = combine_array($array1, $array2); // echo each value and key foreach($combined_array as $value => $key) { echo "<tr>"; echo "<td><input type='hidden' name='branch' value='{$value}'></td>"; echo "<td id='edit'>" . "<input type='submit' name='edit' value='' />" . "</td>"; echo "<td id='sep'> / </td>"; echo "<td><input type='hidden' name='id' value='{$key}'></td>"; echo "<td id='del'>" . "<input type='submit' name='delete' value='' />" . "</td>"; echo "</tr>"; i tried to view the code souce and both hidden fields contain correct data but if i tried to delete/edit it doesn't work. i tried echoing/print_r the $_POST['branch'] & $_POST['id'] after i click on delete/edit and it always gives me the last $value and $key of the combined array for all the submit buttons.. Any thoughts? As i said the appended data is not important but the problem is once i click delete the original values in array1 and 2 are not what post is giving me..therefore i cannot delete or edit them.. Sorry if my post is too long.. Thanks in advance!
-
missing a stupid space in my query $query = "SELECT username, hashed_password"; should be $query = "SELECT username, hashed_password "; [code]
-
Because I'm referring to my db $connection which is located somewhere else.. since it does not change.. making it global makes it available if needed it while not repeating my self over and over again.. Anyways back to my problem, i think i do not need to that since it has mysql_error() already in it and it does report about an error on this line : $query .= "WHERE username = '$username' "; $query .= "AND hashed_password = '$password' "; $query .= " LIMIT 1"; the problem is i dunno what's wrong since like i have told from my 1st post that i have a same script for my email checking which works perfectly and it's this: function check_if_email_exist($email) { global $connection; $query = "SELECT email "; $query .= "FROM users "; $query .= "WHERE email = '$email' "; $query .= " LIMIT 1"; $result_set = mysql_query($query, $connection); confirm_query($result_set); if(mysql_num_rows($result_set) == 1) { return true; } else { return false; } }
-
Gud pm!! So i made this script to check if a username and password exist but it kinda fails me. It gives me a database connection error from my confirm_query() which means it returned false? so here's my code: function check_if_exist($username, $password) { global $connection; $query = "SELECT username, hashed_password"; $query .= "FROM users "; $query .= "WHERE username = '$username' "; $query .= "AND hashed_password = '$password' "; $query .= " LIMIT 1"; $result_set = mysql_query($query, $connection); confirm_query($result_set); if(mysql_num_rows($result_set) == 1) { return true; } else { return false; } } my confirm_query(): function confirm_query($result) { if(!$result) { die("Database connection failure ". mysql_error()); } } I have a another script to check if the email exist and it works perfectly, i dunno why this won't work properly.. :-\ maybe another simple mistake.. Any ideas or Violent reaction? Thanks!
-
@kamal213 i didnt notice your replies since i marked it solved.. if you still have a problem with echoing this: echo $aDays; since its an array, you should do it like this: print_r($aDays);
-
eeeee... your right! im sooo mixed up.. didn't realize it was inside my loop... sorry for bothering you guys, 2hrs of sleep <---- i blame you!!!
-
Thanks for the reply!! Like Muddy Fuster said, that is what i want.. i nid to save $events['event_location'] to $check_location everytime it loops, so if it's the same content it wont repeat it. Sorry if i didnt made it clear.. So.. how can i fix this? Thanks again!
-
Thanks for the reply! you mean this --> "before the loop is finished, $check_location must store a new events['location']..." ? i just made a typo sorry it should be --> "before the loop is finished, $check_location must store a new events['event_location']..." Actually if i change : $check_location = ""; to a known value that $events['event_location'] have, like this : $check_location = "Theater Area"; it actually works.. i think its not passing the new $check_location properly when the loop finishes ( according to me ).. Any ideas?
-
Gud pm! I need some help guys! I made this simple code to compare $check_location to $events['location'] every loop so if they are equal it should not echo what's inside the if statement.. Here's my code: $events_set = select_all_events($mall_id, $month, $year, $public); while($events = mysql_fetch_array($events_set)) { $check_location = ""; if($check_location != trim($events['event_location'])) { $check_location = trim($events['event_location']); echo "<tr>"; echo "<td colspan=7 id='header'>"; echo "<br />"; echo $events['event_location']; echo "</td>"; echo "</tr>"; } before the loop is finished, $check_location must store a new events['location']... I know the problem is kinda simple but the comparison can't seem to work.. Thanks in advance!
-
Right on the spot Muddy_Funster! Thanks!! That's why i don't like putting white space in my db but my boss insist it should be like that, oh well.. Thanks again everyone!! Is there a button for 2ble solved? lol!
-
Holy Mother of Christ! it seems i solved my stupid problem after a short sleep.. i was editing the wrong php file while looking for changes on the wrong php page.... soo lame.. Anyways just for the record, i tried your code harrisweed and it works perfectly! thanks! Can i ask another help? its kinda related to this..or will i put it in another topic? Anyways here it is: I have a user table with a field name of branch where it contains a string like this - > car1 - branch1, car2 - branch2, car3 - branch3... I need to make it an array so i can separate each (car - branch) so i did this code: function display_user_branches($user_id, $branch = NULL) { $branches = get_all_branch($user_id); $all_branches = mysql_fetch_array($branches); $split_branches = preg_split("/,/", $all_branches['brand'], -1, PREG_SPLIT_NO_EMPTY); foreach($split_branches as $value) { echo "<option value='{$value}' "; if($value == $branch) { echo " selected"; } echo ">$value</option>"; } } and is being called by this: echo "<td>"; echo "<select name='branch' >"; display_user_branches($reserved['users_id'], $reserved['branch']); echo "</select>"; echo "</td>"; everything works fine, it displays all car - branch in each option except for the comparison to make it selected. Can't seem to figure out what's wrong.. Again $value and $branch has a format of Car - Branch like my first solved problem.. Maybe i messed up some simple thingy.. Any advice? Thanks in advance!!!!
-
Thanks harristweed ! Ill try that as early as i can tomorrow! @Muddy_Funster Come to think of it.. it may probably the answer.. really don't know cuz i cant check it right now, gonna reply as soon i can test everything out! Thanks for the replies guys!
-
Opppss! should be.. $query = "SELECT * "; any ideas y its not working?
-
Hi! gud pm guys! I have a simple problem which i can't seem to workout so i kinda need your expert help! I'm trying to compare a variable to a string in my db, the variable and the entry on my db has a format of (car - branch), I made this simple function to do that but it doesn't seem to compare properly.. function get_car_code($branch) { global $connection; $query = "SELECT code "; $query .= "FROM car_code "; $query .= "WHERE branch =" . '"$branch"'; $query .= " LIMIT 1"; $result_set = mysql_query($query, $connection); confirm_query($result_set); return $result_set; } when its called back it doesn't return anything.. I'm thinking its the white spaces (or I'm wrong) but i needed them so i cant removed them.. Any suggestions? Thanks in advance!
-
Thanks dharmeshpat! I tried your code but it gave me an error so i modified it to: $query = "SELECT * "; $query .= "FROM events "; $query .= "WHERE malls_id=" . $mall_id; $query .=" AND YEAR(date) =" . $year . " AND MONTH(date) = " . $monthnum; and it works!! I was thinking to do it like that in the 1st place but i read DATE_FORMAT() so i tried it. But in case i want to use DATE_FORMAT() will it work? how?
-
Hi, its me again! So i have this function which gets all the events in my db according to its mall_id and a date (year-month). I merged the $month and $year so i can compare it to the date field in my table. I used DATE_FORMAT to modify my date field so i can compare them but it doesn't seem to work perfectly, function select_all_events($mall_id, $month, $year, $public) { global $connection; $monthname = $month; $monthnum = date("n", strtotime("01-".$monthname."-2011 00:00:00")); if($monthnum < 10) { $monthnum = "0" . $monthnum; } $selected_date = $year . "-" . $monthnum; $query = "SELECT *, DATE_FORMAT(date ,'%Y-%m' ) AS date "; $query .= "FROM table "; $query .= "WHERE malls_id=" . $mall_id; $query .=" AND date =" . $selected_date; if($public == true) { $query .= " AND visible = 1"; } $query .= " ORDER BY date DESC"; $result_set = mysql_query($query, $connection); confirm_query($result_set); return $result_set; } I tried echoing $selected_date, the format is correct, the problem seems to be the comparison.. Also i tried doing it like this: $query = "SELECT * "; $query .= "FROM table "; $query .= "WHERE malls_id=" . $mall_id; $query .=" AND DATE_FORMAT(date ,'%Y-%m' ) =" . $selected_date; but the results are mismatched, like when i choose 2012 January it display's 2011 December ... This dates are making my head dizzy and costing me time..lol Any ideas? Thanks in advance!
-
thanks scootstah! i also replaced my newyear with it.
-
Gud Pm! Im trying to display a list of years (last year, current year and next year) with these simple code i made.. It displays the current and next year correctly except last year, which gives me "1970". I don't get why it gives me that since may next year works properly.. :-\ $currentyear = date('Y'); $subtract_year = strtotime(date('Y', strtotime($currentyear)) . '-1 year'); $lastyear = date('Y', $subtract_year); $addyear = strtotime(date('Y', strtotime($currentyear)) . '+1 year'); $newyear = date('Y', $addyear); $year_array = array($lastyear, $currentyear, $newyear); foreach($year_array as $year) { echo "<option value='{$year}'>"; echo $year; echo "</option>"; } I'm not familiar with dates yet.. so i'm gonna read the manual while w8ting for your kind replies.
-
Thanks requinix! i will try this tomorrow and update you if it did work.
-
Hi again! I'm trying to use this code that i found somewhere in the net to display all the dates between 2 dates. It is exactly what i need but.. I understand the code and its structure (i think) but it gives me an error (maximum execution time of blah blah) which i think is because it makes an infinite loop(not sure.. ) function GetDays($sStartDate, $sEndDate) { $sStartDate = gmdate("Y-m-d", strtotime($sStartDate)); $sEndDate = gmdate("Y-m-d", strtotime($sEndDate)); $aDays[] = $sStartDate; $sCurrentDate = $sStartDate; while($sCurrentDate < $sEndDate){ $sCurrentDate = gmdate("Y-m-d", strtotime("+1 day", strtotime($sCurrentDate))); $aDays[] = $sCurrentDate; } return $aDays; } Appreciate the help and suggestions! Gonna browse the forums for answers for the meantime...
-
sorry AyKay47 i wasn't able to explain how i solved it. Actually its more like a workaround rather than a solid solution. I knew from the beginning (b4 i started this topic) that variable with the same name when combined using the method i posted above will not work i just thought maybe there's an arguments of some sort for array_combine() which i do not know that can be added to make it work and it seems it doesn't have any. Since i really need them to be in array(key=>value) format, First i did some checking in each array if there are duplicate value then i appended each item/string with a (number) before using explode() then array_combine(). Right before inserting them in my db i did: foreach($new as $key => $values) { if(strpos($key, "(") != FALSE) { $key= substr($key, 0, strpos($key, "(")); } $query = "INSERT INTO table (key, value) VALUES ('{$key}', '{$value}' )"; $result = mysql_query($query, $connection); } to remove the appended string.