Jump to content

assgar

Members
  • Posts

    44
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

assgar's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello I am trying to add two records to an array so I can identify which record has a priority 1 or priority 2. This is not working, how do get this to work? <? //get data from database $query = "SELECT a.street, a.city, a.province, b.dob, b.id1_name, b.id1_value, b.id1_priority, b.id2_name, b.id2_value, b.id2_priority FROM pat_address a LEFT JOIN pat_ident b ON a.patient_id = b.patient_id WHERE a.patient_id = '$patient_id' AND a.deleted = 'N' AND b.deleted = 'N' ; $result = mysqli_query ($mysqli, $query); while($row = mysqli_fetch_array($result)) { list($street, $city, $province, $birthday_c, $lang1_code, $id_priority1, $id_name1_c, $id_value1, $id_priority2, $id_name2_c, $id_value2, ) = $row; } //if a priority exists add the data to array $id_array = array();//identify array if(!empty($id_priority1) && $id_priority1 > 0) { $id_array['pri'] = $id_priority1;//priority $id_array['name'] = $id_name1_c; //name $id_array['value'] = $id_value1; //value } if(!empty($id_priority2) && $id_priority2 > 0) { $id_array['pri'] = $id_priority2; //priority $id_array['name'] = $id_name2_c; //name $id_array['value'] = $id_value2; //value } //sort into priority 1 & 2 foreach ($id_array AS $idray) { echo"()".$idray['pri']; switch($idray['pri']) { case'1': $name1 = $idray['name']; $value1 = $idray['value']; $priority1 = $idray['pri']; break; case'2': $name2 = $idray['name']; $value2 = $idray['value']; $priority2 = $idray['pri']; break; } } ?>
  2. Thanks for the response. I was able to correct my error. Below are three approaches that works //Test 1 works $query = "SELECT userid, first_name, last_name FROM users WHERE username IN ('".implode("','",$per_list)."') AND org_code = '$org_code' AND deleted = 'N'"; $result = mysqli_query ($mysqli, $query) or die("Error: ".mysqli_error($mysqli)); while($row = mysqli_fetch_array($result)) { $per[] = $row; } //Test 2 works $per_list = implode("', '", $per_list); $query = "SELECT userid, first_name, last_name FROM users WHERE username IN ('$per_list') AND org_code = '$org_code' AND deleted = 'N' "; $result = mysqli_query ($mysqli, $query) or die("Error: ".mysqli_error($mysqli)); while($row = mysqli_fetch_array($result)) { $per[] = $row; } //test 3 works $query = "SELECT userid, first_name, last_name FROM users WHERE username IN ('".join("','", array_values($per_list))."') AND deleted = 'N'"; $result = mysqli_query ($mysqli, $query) or die("Error: ".mysqli_error($mysqli)); while($row = mysqli_fetch_array($result)) { $per[] = $row; }
  3. I am trying to use a single select to get the first and last name for a group of users. Here are the two approaches (Test 1 & Test 2) I tried to get the data. Both approach gave the same error. Error: Unknown column 'norma' in 'where clause' What is wrong with my approch(s)? <? //open connection $mysqli = db_connect(); db_select($mysqli, $db_id); //initiate array $per_list = array(); $per = array(); //assign values of user name to array $per_list[] = "norma"; $per_list[] = "alex"; $per_list[] = "sean"; /**Test 1**/ $query = "SELECT userid, first_name, last_name FROM users WHERE username IN (".implode(',',$per_list).")"; $result = mysqli_query ($mysqli, $query) or die("Error: ".mysqli_error($mysqli)); while($row = mysqli_fetch_array($result)) { $per[] = $row; } /**Test 2**/ $per_list = implode(", ", $per_list); $query = "SELECT userid, first_name, last_name FROM users WHERE username IN ($per_list)"; $result = mysqli_query ($mysqli, $query) or die("Error: ".mysqli_error($mysqli)); while($row = mysqli_fetch_array($result)) { $per[] = $row; } ?>
  4. Hello The problem still exists as described. I was trying to keep it simple, below is the function call being used. NOTE: The function is a separate script that is linked to the page using <? include("../display"); //link separate script test_display($searching, $field, $find);//call function ?>
  5. Hello I am experiencing some issues with a function and I cannot identify the problem. The function is not receiving any parameter. The URL values are passed correctly. I used echo to display the parameters outside the function and that worked. I also used echo to display the parameters inside the function and no parameter were displayed. So the function is not receiving parameters. <?php $find = $_REQUEST['u_find']; $field = $_REQUEST['u_field']; $searching = $_REQUEST['u_search']; echo"(1a)$find, (1b)$field, (1c)$searching";//outside function function test_display($searching, $field, $find) { echo"(2a)$find, (2b)$field, (2c)$searching";//inside function } ?>
  6. Hello I have made some changes that provise some hope. When I select the link the sticky form works and the values are not lost. The url display the value for the selected option. The is problem I am now having is with the $option = $_REQUEST['u_source_id']; it is not receiving the url value. The php if statement is not displaying the information related to the user selection. <? /** page: page_list_form.php **/ include("../reqin/title_in.php");//title drop down $option = $_REQUEST['u_source_id']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!-- <!DOCTYPE html PUBLIC "-//W3C/DTD//xhtml 1.0 transitional//EN" "http://www.w3.org/tr/xthtml1-transitional.dtd"> --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org" /> <title></title> <script type="text/javascript"> //<![CDATA[ function() { document.getElementById('op_link').onclick = function() { var form; form = document.getElementById('calendar'); form.elements.link = this.href; form.submit(); }; } //]]> </script> </head> <body> <form id="calendar" action="process.php>" method="post"> <? echo"<table><tr> <td width='30%'> <input type='text' name='first_name' value='$first_name' width='95%'/></td>"; echo"<td width='30%'> <input type='text' name='last_name' value='$last_name' width='95%'/></td> <td width='30%'>"; title($code);//dropdown with titles echo" </td> <td>"; /**display option selection**/ if($option == "p1") { echo"Option One"; } elseif($option == "p2") { echo"Option Two"; } echo"<input type='hidden' name='option' value='$option'/>";//option value passed to database echo"</td></tr> <tr>"; /**link to select and refresh page and keep title, first & last name **/ /** submit data to database**/ echo"<td><input type='submit' name='Submit'/></td> </tr></table>"; ?> </form> </body> </html>
  7. Hello I am new to JavaScript and need some assistance. I am trying to create a page/form where the user enters first and last name and select their title (Mr, Miss or Mrs). There is also the ability to select 1 of 2 options by clicking a link. After the name, title and option is selected the data is sent to the database using a submit button The problem is when the link is selected and page refreshes and all the data is lost because the sticky page is not working. <? /** page: page_list_form.php **/ include("../reqin/title_in.php");//title drop down $option = $_REQUEST['u_source_id']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!-- <!DOCTYPE html PUBLIC "-//W3C/DTD//xhtml 1.0 transitional//EN" "http://www.w3.org/tr/xthtml1-transitional.dtd"> --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org" /> <title></title> <script type="text/javascript"> //<![CDATA[ function OnClick() { var title = document.getElementById('TitleId').value; calForm = document.getElementById("calendar"); calForm.setAttribute("action", "<?=$_SERVER['PHP_SELF']?>?u_title="+title); calForm.submit(); // submit it, keeping POST vars } //]]> </script> </head> <body> <form id="calendar" action="process.php>" method="post"> <? echo"<table><tr> <td width='30%'> <input type='text' name='first_name' value='$first_name' width='95%'/></td>"; echo"<td width='30%'> <input type='text' name='last_name' value='$last_name' width='95%'/></td> <td width='30%'>"; title($code);//dropdown with titles echo" </td> <td>"; /**display option selection**/ if($option == "p1") { echo"Option One"; } elseif($option == "p2") { echo"Option Two"; } echo"<input type='hidden' name='option' value='$option'/>";//option value passed to database echo"</td></tr> <tr>"; /**link to select and refresh page and keep title, first & last name **/ echo" <td><div id='blue-listing'><a href ='../page_list_form.php?u_source_id=p1' onclick='javascript:OnClick();'>Option 1</a></div></td> <td><div id='blue-listing'><a href ='../page_list_form.php?u_source_id=p2' onclick='javascript:OnClick();'>Option 2</a></div></td> <td> </td>"; /** submit data to database**/ echo"<td><input type='submit' name='Submit'/></td> </tr></table>"; ?> </form> </body> </html>
  8. Hello The problem was solved here is the solution: $exist = array();//create array //store values in array $query = "SELECT type FROM contact WHERE id ='$id' AND deleted = 'N' ORDER BY type"; $result = mysqli_query ($mysqli, $query); while($row = mysqli_fetch_array($result)) { $exist[] = $row[0]; }
  9. Hello I am having a problem getting the difference between two arrays. The first array $list has all codes that can be linked to a specific id The second array $exist has the values select and linked to a specfic id. Both arrays are storing integers array $list should have 110,111,112,113,114,115. Array $exist gets 110, 114 115 from the database the difference should be 111 & 112 I think the problem is with array $exist that is getting its values from the database. Could the problem be that the arrys are storing data differently? How do I resolve this problem? /**==========ARRAY 1=======**/ /**All values for this type in array for comparison against**/ $list = array('110','111','112','113','114','115'); /**view values in array $list**/ var_dump($list); array(6) { [0]=> string(3) "110" [1]=> string(3) "111" [2]=> string(3) "112" [3]=> string(3) "113" [4]=> string(3) "114" [5]=> string(3) "115" } /**==========ARRAY 2=======**/ /**Get stored types for specific id **/ $exist = array();//create array //store values in array $query = "SELECT type FROM contact WHERE id ='$id' AND deleted = 'N' ORDER BY type"; $result = mysqli_query ($mysqli, $query); while($row = mysqli_fetch_array($result)) { $exist[] = $row; } /**View values in array for specific id in array $exist**/ var_dump($exist); array(3){ [0]=>array(2){ [0]=>string(3) "110" ["contact_type"]=> string(3) "110"} [1]=> array(2){[0]=> string(3) "114" ["contact_type"]=> string(3) "114"} [2]=> array(2){ [0]=> string(3) "115"["contact_type"]=> string(3) "115"}} /**==========RESULT=======**/ /**Get the difference between all possible type and stored values linked to a specific id **/ $difference = array_diff($list, $exist); /**viewthe difference between the two arrays**/ var_dump($difference); array(6) { [0]=> string(3) "110" [1]=> string(3) "111" [2]=> string(3) "112" [3]=> string(3) "113" [4]=> string(3) "114" [5]=> string(3) "115" }
  10. Hello I would like to hide the address bar or contents for Firefox and internt Explorer. What is the best way to accomplish this? Will I still be able to pass values to other pages using the hidden address bar? Note: I am using PHP, Mysql. These pages will run on windows and linux servers. Thanks in advance
  11. Hi Thanks for responding. I am getting the correct hours and minutes by removing the seconds. E.g. date("h:i",strtotime($end_time)). I am still open to a more efficient way to accomplish this task. [code] <? $end_time = "2008-09-05 20:59:13"; $start_time = "2008-09-05 19:00:16"; $end = date("h:i",strtotime($end_time)); $start = date("h:i",strtotime($start_time)); $diff = strtotime($end) - strtotime($start); //convert to min and sec $convert_min = $diff/60; $convert_sec = $diff % 60;//seconds //convert to hours and min $convert_hr = floor($convert_min/60);//hours $remainder = floor($convert_min % 60);//minutes $total_visit = $convert_hr.":".$remainder; ?> [/code]
  12. Hi I am trying to get the number of hours and minutes between two time time stamps. The expected results should be 1:59 (h:mm) instead I am getting 1:58 (h:mm). What is wrong with my approach? Is it also possible to use a built in php function so I don't have to divide by 60 to convert to hours and minutes? [code] <? $end_time = "2008-09-05 20:59:13"; $start_time = "2008-09-05 19:00:16"; $end = date("h:i:s",strtotime($end_time)); $start = date("h:i:s",strtotime($start_time)); $diff = strtotime($end) - strtotime($start); //convert to min and sec $convert_min = $diff/60; $convert_sec = $diff % 60;//seconds //convert to hours and min $convert_hr = floor($convert_min/60);//hours $remainder = floor($convert_min % 60);//minutes $total_visit = $convert_hr.":".$remainder; ?> [/code]
  13. Hi The goal is to allow the user the ability to compare daily schedules of between 1 to 7 users. The number of columns/user schedule and column headers are dynamically created base on user selection. Each user schedule is set up in columns with the user name at the top of the column and appointments in the columns. For a static number of columns in a loop I would use the approach below to display client names for columns. I am having problems creating dynmic unique column array names for client_name. [code] //static columns for() { echo"<tr> <td>$client_name1</td> <td>$client_name2</td> <td>$client_name3</td> <td>$client_name4</td> <td>$client_name5</td> <td>$client_name6</td> </tr>"; } [/code] [code] <? function calendar_event_list_play($users, $date, $db_host, $db_user, $db_password) { //database connnection goes here /**-------------selected database contents stored in arrays---------**/ $group_seg[] = $row;//get user availability $events[] = $row;//appointments for users $provider[] = $row;//users names for column header $width = 23;//dymanic column width calculation base on number of user schedules selected /**--------------header with user names--------------**/ echo"<table> <tr>"; //appointmant time header echo"<td width='$time_slot%'>Time</td>"; //user name column header for($num = 0; $num < count($provider); $num++) { $last_name = $provider[$num][last_name];//get provider last name for title echo"<td width='$width%'><a href ='../calendar_form.php>$provider_name</a></td>"; } echo "</tr> </table>"; echo "<table width='100%'>\n"; //Loop over to display appointment time 15 min time slots for($time = $start_time; $time <= $end_time; $time += $add_time) { //format 24 hour time interval for passing via url $interval_24hr = date("H:i:s", $time); /**-----------------------event time listing ------------------------**/ echo "<tr>"; //Output the time interval label echo"<td width='8%' height='15'> <div id='cal-number' style =''> <ul> <li>".date("h:i A", $time)."</li> </ul> </div> </td>"; //number of columns for($i = 0; $i < count($provider); $i++) { //loop to display appointments for column foreach ($events as $event) { //Event falls into this hour if($interval_24hr == $event['event_time']) { $client_name = substr($event['last_name'],0,14); } else { $client_name = ""; } }//end foreach //number of user columns dynamic with appointments displayed echo"<td $width%'><a href ='../calendar_event_manage_form.php>$client_name</a></td>"; } echo "</tr>"; } echo "</table>"; }//end function ?> [/code]
  14. Hi thanks for responding After various approaches that worked partially this is the solution. I am open to suggestions on improving on it. NOTE:I have temporarily removed the appointments loop to focus on the event type looping. <? //work hours $min_start1 = "09:30:00";//earliest appointment $start_time = "09:00:00";//office hours $end_time = "05:00:00"; //get availability nfo /** selected data time_id, week_day, start_date, end_date, start_time, end_time, colour in array**/ $avail_days; //availaibility /**selected data event_id, event_name, event_date, event_time in array**/ $events;//appointment echo"<table>"; //Loop over the hours for ($time = $start_time; $time <= $end_time; $time += $add_time) { //format 24 hour time interval for passing via url $interval_24hr = date("H:i:s", $time); /**-----------------------event time listing and event type------------------**/ echo "<tr>"; //Output the time interval label echo"<td width=\"8%\" height=\"15\" bgcolor=\"\" align=\"center\"> <ul> <li>".date("h:i A", $time)."</li> </ul> </td>"; /**----------------------event type display------------------------------**/ //loop through array to diaplay event type colour and labeling foreach ($avail_days as $avail_day) { //day of the week Mon to sun $seg_day = $avail_day['week_day']; //diaplay event type colour and labeling to event end time //monday if($seg_day == 1 && $interval_24hr >= $avail_day['start_time'] && $interval_24hr <= $end_time) { $colour1 = "#".$avail_day['colour']; } elseif($seg_day == 1 && $interval_24hr > $end_time || $seg_day == 1 && $interval_24hr < $min_start1) { $colour1 = "#ebeae0";//default background colour } //tuesday if($seg_day == 2) { /*note: for tuesday to sunday not listed for space reasons it is the same as for monday except $colour2 etc is used*/ ..... } /**----------------------event--------------------**/ /*loop to provide appointment linked to appropriate event time slot goes here*/ /**------------------dynamic looping rows and columns--------------**/ echo'<td width="13%" height="12" bgcolor="$colour1"> $event_name1</td> <td width="13%" height="12" bgcolor="$colour2"> $event_name2</td> <td width="13%" height="12" bgcolor="$colour3"> $event_name3</td> <td width="13%" height="12" bgcolor="$colour4"> $event_name4</td> <td width="13%" height="12" bgcolor="$colour5"> $event_name5</td> <td width="13%" height="12" bgcolor="$colour6"> $event_name6</td> <td width="13%" height="12" bgcolor="$colour7"> $event_name7</td>"; echo"</tr>\n'; } echo"</table>"; ?>
  15. Hi thanks for responding I made the rows easier to read. But that is not my problem it’s the looping. I have worked the code and have all the event types showing for each day column. Which is what I am trying to accomplish. The problem is the if the person is working a short day i.e. 9:00AM to 12:00PM the last type colour for the short day fills the time slots to 5:00PM instead of stopping at 12:00pm. I have tried else statement to empty the $seg_colour array with no luck. This if statement is to match the event type time to the listed time of day. Should this not prevent unrelated event types from showing? if($interval_24hr >= $avail_day['type_start_time'] && $interval_24hr <= $avail_day['type_end_time']) NOTE:I have temporarily removed the appointments loop to focus on the event type looping. <? //work hours $start_time = "09:00:00"; $end_time = "05:00:00"; //get availability nfo /** selected data time_id, week_day, start_date, end_date, start_time, end_time, colour in array**/ $avail_days; //availaibility /**selected data event_id, event_name, event_date, event_time in array**/ $events;//appointment echo"<table>"; //Loop over the hours for ($time = $start_time; $time <= $end_time; $time += $add_time) { //format 24 hour time interval for passing via url $interval_24hr = date("H:i:s", $time); /**-----------------------event time listing and event type------------------**/ echo "<tr>"; //Output the time interval label echo"<td width=\"8%\" height=\"15\" bgcolor=\"\" align=\"center\"> <ul> <li>".date("h:i A", $time)."</li> </ul> </td>"; /**----------------------event type display------------------------------**/ //loop through array to diaplay event type colour and labeling foreach ($avail_days as $avail_day) { //diaplay event type colour and labeling to event end time if($interval_24hr >= $avail_day['type_start_time'] && $interval_24hr <= $avail_day['type_end_time']) { $seg_colour = "#".$avail_day['colour']; $time_id = $avail_day['time_id']; $seg_day = $avail_day['week_day']; //monday if($seg_day == 1) { $colour1 = $seg_colour; } //tuesday elseif($seg_day == 2) { //note elseif for tuesday to sunday not listed for space reasons ..... } /**----------------------event--------------------**/ /*loop to provide appointment linked to appropriate event time slot goes here*/ /**------------------dynamic looping rows and columns--------------**/ echo'<td width="13%" height="12" bgcolor="$colour1"> $event_name1</td> <td width="13%" height="12" bgcolor="$colour2"> $event_name2</td> <td width="13%" height="12" bgcolor="$colour3"> $event_name3</td> <td width="13%" height="12" bgcolor="$colour4"> $event_name4</td> <td width="13%" height="12" bgcolor="$colour5"> $event_name5</td> <td width="13%" height="12" bgcolor="$colour6"> $event_name6</td> <td width="13%" height="12" bgcolor="$colour7"> $event_name7</td>"; echo"</tr>\n'; } echo"</table>"; ?>
×
×
  • 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.