<?
$id_array = array();//identify array
if(!empty($id_priority1) && $id_priority1 > 0)
{
$id_array[] = array('pri' => $id_priority1, 'name' => $id_name1_c, 'value' => $id_value1);
}
elseif(!empty($id_priority2) && $id_priority2 > 0)
{
$id_array[] = array('pri' => $id_priority2, 'name' => $id_name2_c, 'value' => $id_value2);
}
?>
//I tried the changes below and could not get it to work.
<?
if(!empty($id_priority1) && $id_priority1 > 0)
{
$id_array[0][] = array('pri' => $id_priority1, 'name' => $id_name1_c, 'value' => $id_value1);
}
elseif(!empty($id_priority2) && $id_priority2 > 0)
{
$id_array[1][] = array('pri' => $id_priority2, 'name' => $id_name2_c, 'value' => $id_value2);
}
?>
//I got this to work:
<?
$id_array = array();//identify array
if(!empty($id_priority1) && $id_priority1 > 0)
{
$id_array[0]['pri'] = $id_priority1;
$id_array[0]['name'] = $id_name1_c;
$id_array[0]['value'] = $id_value1;
}
if(!empty($id_priority2) && $id_priority2 > 0)
{
$id_array[1]['pri'] = $id_priority2;
$id_array[1]['name'] = $id_name2_c;
$id_array[1]['value'] = $id_value2;
}
?>
assgar 14 Junior Poster in Training
Thanks for responding.
What is the benifit of placing the $id_array = array(); before the While loop when the array is not being populated by the while loop?
I chose not to use the while loop because I wanted to manually add the the two related records.
assgar 14 Junior Poster in Training
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;
}
}
?>
assgar 14 Junior Poster in Training
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; } ?>
Thanks for the response. Your suggeston show another great way to accomplish the task.
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 …
assgar 14 Junior Poster in Training
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;
}
?>
assgar 14 Junior Poster in Training
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
}
?>
assgar 14 Junior Poster in Training
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>
assgar 14 Junior Poster in Training
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 …
assgar 14 Junior Poster in Training
Hello
Thanks for the suggestion.
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];
}
assgar 14 Junior Poster in Training
Title: Comparing arrays
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 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 …
assgar 14 Junior Poster in Training
Hello
This was a great exerecise. I learned alot more how
to use javascript
I have two ways to accomplish the task of having a sticky
form that also display database derived dynamic listing.
The listing search is determined by a dropdown selection.
The idea was also not to use any buttons to enable the
sticky and dynamic listing display.
----------------------solution 1---------------
Uses $_POST to capture values. This form would also process
its data for database storage.
<?
include("../calendar.php");//display dynamic appointment calendar
include("../people_list.php");//drop down of names list
//capture & clean up user input
$test1 = strip_tags(trim($_POST['test1']));
$test1 = preg_replace("/[^a-zA-Z0-9\s,.]+/","",$test1);
$test2 = strip_tags(trim($_POST['test2']));
$test2 = preg_replace("/[^a-zA-Z0-9\s,.]+/","",$test2);
$test3 = strip_tags(trim($_POST['test3']));
$test3 = preg_replace("/[^a-zA-Z0-9\s,.]+/","",$test3);
$pro_id = strip_tags(trim($_POST['pro_id']));
?>
<!-- Note: used for all test removed for this example from test 2 and test2 -->
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<script language="JavaScript" type="text/JavaScript">
<!--
function OnChange()
{
var pro_id = document.getElementById('providerId').getAttribute("value"), calForm = document.getElementById("calendar");
calForm.setAttribute("action", "<?=$_SERVER['PHP_SELF']?>?pro_id=" + pro_id); // change action for form
calForm.submit(); // submit it, keeping POST vars
}
-->
</script>
</head>
<body>
<form action="<?php $_SERVER['PHP_SELF'];?>" name="calendar" id = "calendar" method="POST">
<table>
<tr>
<td width="25%"><input type="text" name="test1" value="<?=$test1?>"/></td>
<td width="25%"><input type="text" name="test2" value="<?=$test2?>"/></td>
<td width="25%"><input type="text" name="test3" value="<?=$test3?>"/></td>
<td>
<select name= "provider_id" id="providerId" onchange="javascript:OnChange();">
<?
//display lastname and first name initial
first_last_name_display($db_id);
?>
</select>
</td>
</tr>
</table>
<?php
//function display dynamic appointment calendar
calendar_play($pro_id, $db_host, $db_user, $db_password, $db_id); …
peter_budo commented: Thank you for sharing solution :D +14
assgar 14 Junior Poster in Training
Sticky note refresh not working
Hello
I am trying to create a sticky form.
I would like to use javascript to refresh the page using drop
down selection to trigger the refresh.
The problem is I cannot get it to work. See test3.
I tried two other example that worked with a submit button and no javascript
See test 1 and test 3.
If you have any suggestions that would be great.
Note:Below you will find 3 tests I used to identify that it is the javascript
that is causing the problem.
Using Win 2003 server, Php, Apache and Mysql.
Thanks
<!-- Note: used for all test removed for this example from test 2 and test2 -->
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<!-- test # 1 -->
The sticky works for this test
<?php
$test1 = $_POST['test1'];
$test2 = $_POST['test2'];
$test3 = $_POST['test3'];
?>
<script language="JavaScript" type="text/JavaScript">
<!--
-->
</script>
</head>
<body>
form action="<?php $_SERVER['PHP_SELF'];?>" name="calendar" method="POST">
<table>
<tr>
<td width="25%"><input type="text" name="test1" value="<? echo $test1; ?>"/></td>
<td width="25%"><input type="text" name="test2" value="<? echo $test2; ?>"/></td>
<td width="25%"><input type="text" name="test3" value="<? echo $test3; ?>"/></td>
<td width="25%"><input type="submit" value="Submit"/></td>
</tr>
</table>
</form>
</body>
</html>
<!-- test # 2 -->
The sticky works for this test
<script language="JavaScript" type="text/JavaScript">
<!--
-->
</script>
</head>
<body>
form action="<?php $_SERVER['PHP_SELF'];?>" name="calendar" method="POST">
<table>
<tr>
<td width="25%"><input …
assgar 14 Junior Poster in Training
Lets take another approach.
For example we will use the addess to this poft.
I don't mind the user seeing Part A of the browser address
But I don't want them seeing the folder the pages are in and the other details passed by the URL.
A user can change the info in the URL and I also don't want that.
Part A
http://www.daniweb.com
Part B
/forums/showthread.php?p=775555&posted=1#post775555
Thanks
assgar 14 Junior Poster in Training
Hello.
We have an online library system on a specific computer, which can only be used for searching for books. It does not have the address bar showing anywhere.
Is this the sort of thing you are talking about, or do you want it to work on all computers which access the website?
Hi Thanks for responding.
That is what I am talking about.
This application is for a specific purpose. You can searcing the data base for information you have stored.
User name a pass word control access.
assgar 14 Junior Poster in Training
Thanks for responding.
I will be hiding the address bar for security reason. Also in the web base application the user will not be using the address bar for searching. Access to this application is limited to specific users.
So should I assume from your response you don't know how to do this?
assgar 14 Junior Poster in Training
Hello
I would like to hide the address bar 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
assgar 14 Junior Poster in Training
Hi
My menu list displays correctly for Internet explorer.
I am having problems with my menu list display properly in firefox.
The row height should be 15px, but in firefox the row display twice as height than in IE.
Note:
The menue display a link, mouse over should change the colour of the link and it background
OS:Win server 2003
Language: PHP
How can I resolve this issue?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="mazuki" />
<link href="../config/pulse_config.css" rel="stylesheet" type="text/css"/>
<style type="text/css">
<!--
.default
{
margin-left:0;
margin-right:0;
text-align:center;
font-family: Arial, Helvetica, sans-serif;
font-size:14px;
font-weight:600;
vertical-align:top;
}
.default ul
{
margin-left:0;
padding-left:0;
white-space:nowrap;
}
.default li
{
display:inline;
list-style-type:none;
}
.default a
{
padding:3px 10px;
}
.default a:link
{
color:#ffffff;
background-color:#036;
text-decoration:none;
}
.default a:visited
{
color:#ffffff;
background-color: #000000;
text-decoration:none;
}
.default a:hover
{
color:blue;
background-color:#55ae3a;
text-decoration:none;
}
-->
</style>
<title>Home Page</title>
</head>
<body bgcolor="#e0e0e0">
<!-- processor -->
<form action="process.php" method="post">
<div id="pat-dash-first-layer">
<table height="30" width="100%" border="1">
<tr height="15">
<td height="39" align="right"><div class="default"><ul><li><a href ="../change_form.php">Change Password</a></ul></li></div></td>
</tr>
<tr height="15" align="center">
<td width = "100%"colspn ="2"><div id="location-bar" >Home Page</div></td>
</tr>
</table>
</form>
</body>
</html>
assgar 14 Junior Poster in Training
Thanks for the solutions.
Enabling cookie was the temporary solution.
I will store the session info in a database.
How do I accomplish the example below if I disable cookies?
example:
I have a 20 pages I need to pass the same user preferences\permissions\data across. I have been using sessions in IE and it works. I want to move to Firefox.
Note: The total of 15 to 20 preferences\permissions\data are stored in mysql DB and security is important.
I would prefer not to have to select the preferences\permissions\data from the database for each page.
assgar 14 Junior Poster in Training
Hi
I am having problems with sessions.
When using Internet Explorer I can pass sessions to other pages.
I cannot pass sessions when I use Mozilla Firefox.
//at the top of the page
session_start();
//value passed
$last_login = $_SESSION['s_last_login'];//last user login history
PHP.ini:
//This is my PHP.ini file session configuration below.
[Session]
; Handler used to store/retrieve data.
session.save_handler = files
;session.save_path = "N;/path"
;session.save_path = "N;MODE;/path"
;session.save_path = "/tmp"
session.use_cookies = 1
session.name = PHPSESSID
;Initialize session on request startup.
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 100
session.gc_maxlifetime = 1440
session.bug_compat_42 = 1
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
;session.entropy_length = 16
;session.entropy_file = /dev/urandom
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 4
assgar 14 Junior Poster in Training
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.
<?
$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;
?>
assgar 14 Junior Poster in Training
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?
<?
$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;
?>
assgar 14 Junior Poster in Training
Hi
Thanks for the response and suggestion.
I could not a single function to work.
I could get 2 seperate functions working and it does the job.
I am curious why your suggestion won;t work as one function but will wor as two?
solution
<html>
<head>
<script language="javascript" type="text/javascript">
function YearChange()
{
var year = document.getElementById('year').value;
window.location.href="http://localhost/month_view.php?year=" + year;
}
function ProChange()
{
var providerId = document.getElementById('provider_id').value;
window.location.href="http://localhost/month_view.php?u_org_pro_id=" + providerId;
}
</script>
</head>
<body>
<table>
<tr><td>
<select name= "year" onchange="javascript:YearChange();">
<?
//dynamic year dropdown 14 years (4 back, current and 9 forward)
year_only($year);
?>
</select>
<select name= "user_id" onchange="javascript:ProChange();">
<?
//display information based on selected year, month and user
display_info($year, $month, $user);
?>
</select>
</td>
</tr>
</table>
</body>
</html>
assgar 14 Junior Poster in Training
Hi
I am new to javascript.
I have two drop downs used to reload the page displaying selected information.
How do I get the OnChange function to pass year and user form the drop down.
I also need to pass data in the array $month.
<html>
<head>
<body>
<script language="JavaScript" type="text/JavaScript">
<!--
function OnChange(dropdown)
{
//reload page after drop down selection
window.location.href="http://localhost/month_view.php?u_user_id=" +
dropdown.options[dropdown.selectedIndex].value "&year="+ "&month="+ ;
}
--->
<table>
<tr><td>
<!--year drop down-->
<select name ="year" onChange ="javascript:OnChange(this)"
<option value="">Select</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
</select>
<select name = "user_id" onChange ="javascript:OnChange(this)"
<option value="">Select</option>
<option value="1">Frank</option>
<option value="2">Mark</option>
</select>
</td>
</tr>
<tr>
<td>
<?php
//display information based on selected year, month and user
display_info($year, $month, $user);
?>
</td>
</tr>
</table>
</body>
</head>
</html>
assgar 14 Junior Poster in Training
Thanks for the suggestions I will try it.
assgar 14 Junior Poster in Training
Thanks it worked.
assgar 14 Junior Poster in Training
Hi
I would like to put a list of ids in an array
and loop to select data from a table using
"IN" in the where clause.
I am not having any success getting this to work.
Any suggestions?
Note:I am using Mysql database, apache, linux/Windows
<?
//array with list of friends to display
$friend = array('1','2','3','4');
$query = "SELECT first, last, number
FROM friend
WHERE id IN '$friend'";
$result = mysqli_query($mysqli, $query);
assgar 14 Junior Poster in Training
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.
//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:
<?
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' …
assgar 14 Junior Poster in Training
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 …
assgar 14 Junior Poster in Training
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 …
assgar 14 Junior Poster in Training
Hi
Thanks for the reply.
The days in column format for the week is displaying correctly.
The current problem is when the foreach loop ends in position # 1
only the last iteration of the loop is displayed.
When the foreach loop ends in position # 2 to try and display
all the iteration of the array. The event time displays but the
event colour ($colour1 ... $colour7) does not.
It appears
<?
//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_day; //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);
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>";
//loop to display days of the week
foreach($avail_day as $key => $avail)//rows
{
//diaplay event type colour and labeling to event end time
$seg_code = $avail_day['event_type_code'];
$time_id = $avail_day['time_id'];
$seg_day = $avail_day['week_day'];
//monday
if($seg_day == 1 && $interval_24hr >= $avail_day['start_time']&&
$interval_24hr <= $avail_day['end_time'])
{
$colour1 = "#".$avail_day['colour'];
}
elseif($seg_day == 1)
{
$colour1 = "#ebeae0";
}
//note tuesday to sunday not listed for space reasons
foreach($events as $key => $event)
{
//determine day of week
$week_day = date('l',strtotime($event['event_date']));
//appointment or name description
if($week_day == "Monday" && $event_time >= $time …
assgar 14 Junior Poster in Training
Hi
I have 7 arrays for all containing the same data:time_id,
start_time, end_time and colour.
Each array represent a day of the week.
There are a total of seven columns to display.
I have combined them into a three multi dimentional to
display data form the 7 layers which are the days.
Is this the best way to accomplish my goal?
The results are not what displaying properly.
The columns are all not starting at the top of the screen and they should.
note: This is the result, each line represents the top of a column.
The columns should be at the same level.
|------|
|------|-------|
|------|-------|-------|
|------|-------|-------|-------|
|------|-------|-------|-------|-------|
|------|-------|-------|-------|-------|-------|
|------|-------|-------|-------|-------|-------|--------|
|------|-------|-------|-------|-------|-------|--------|
<?
echo"<table>";
//get availability nfo
$query = "SELECT DISTINCT(a.time_id), a.start_time, a.end_time, c.colour
FROM available a, type_display c
WHERE a.type_code = c.type_code
AND '$event_date' BETWEEN a.start_date AND a.end_date
AND a.org_pro_id = '$org_pro_id'
AND a.week_day = '$day'
GROUP BY a.start_time";
$result = mysqli_query($mysqli, $query) or die('Error, query failed');
while($row = mysqli_fetch_array($result))
{
$avail_day1[] = $row; //this only shows one of the seven days to save on clutter
}
/**Note:all contain table data time_id, start_time, end_time, colour**/
$all_avail_days = array($avail_day1, $avail_day2, $avail_day3, $avail_day4,
$avail_day5, $avail_day6, $avail_day7);
for($wk_day =0; $wk_day < count($all_avail_days); $wk_day++)//wk_day layer
{
$day = $wk_day + 1; echo":";
foreach($all_avail_days as $key => $avail)//rows
{
for($j = 0; $j < count($all_avail_days[$key]); $j++)//column
{
if($day == 1)
{ …
assgar 14 Junior Poster in Training
It could be my work, but I find isset() not always as reliable as empty().
I check form field because it is preloaded with information using $reason array.
assgar 14 Junior Poster in Training
Hi
Thanks for responding.
I will try the version of code you seggested
I did tried this before posting but the data was still lost:
<?
<input type="text" name="reason" size="30" maxlength="60"
value="<?php if(! empty($_POST['reason'])){echo $_POST['reason'];} else
{echo"$reason";}?>">
?>
assgar 14 Junior Poster in Training
Hi
I was using PHP sessions to create a sticky form but a
button was needed to reload the page.
I am new to Java and I have decided to do away with the button.
Using onChange="javascript:OnChange(this) to cause the
page to reload once a selection is made from a dynamic dropdown works.
The problem is the input box and other dropdown on the same page lose
their information. How can I create a sticky form that is
compatible with onChange?
Thanks
<?
include("../priority_low_to_high_in.php");//proiority drop down
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Calendar</title>
<link href="../config.css" rel="stylesheet" type="text/css"/>
<script language="JavaScript" type="text/JavaScript">
<!--
function OnChange(dropdown)
{
window.location.href="http://localhost/search_form.php?pro_id=" +
dropdown.options[dropdown.selectedIndex].value;
}
function MM_reloadPage(init)
{ //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<style type="text/css">
<!--
-->
</style>
</head>
<!-----------------------form processor---------------------------->
<form action="../search_process.php" name="calendar" method="post">
<tr>
<td>
<select name= "provider_id" onChange="javascript:OnChange(this);">
<?
//display lastname and first name
provider_first_last_name_display($name, $name_val, $db_id);
?>
</select>
</td>
</tr>
<tr>
<td>
<!---reason input---->
<input type="text" name="reason" size="30" maxlength="60" value ="<?php echo $reason; ?>">
</td>
</tr>
<tr>
<td>
<!--priority dropdown-->
<select name="priority">
<?php
$priority_name = get_b_priority_name($b_priority_n);
$priority_code = get_b_priority_code($b_priority_c);
for($n = 1; $n<= 6; $n++)
{
$sname = $priority_name[$n];
$scode = $priority_code[$n];
echo "<option value = '$scode'";
if ($scode == " ")
{
echo "selected";
}
echo "> $sname"; …
assgar 14 Junior Poster in Training
Hi
I am trying to display appointments in a database and would like
to display all appointments for a week.
The time of the day appears on the left and vertical columns with
the names of appointments on the right.
The code below only generates a single column of names.
Would
Time Mon Tue Wed Thu Fri Sat Sun
----------------------------------------------------------------------
07:00AM name name name name name name
----------------------------------------------------------------------
07:15AM name name name name name name
------------------------------------------------------------
to
------------------------------------------------------------
04:00PM name name
<?
function calendar_event_list_play($date $db_host, $db_user, $db_password, $db_id)
{
//connnect to database script here
/**---------------get first day of the week for date ---------------**/
/**subtract the difference between monday of the week and start date from
start_date for the start_date**/
$new_start = "2008-03-04";
/**-------------------------week day dates--------------------------**/
//monday
$date_day1 = date("Y-m-d",strtotime($new_start));
$week_day1 = "Mon";//550
//tuesday
$wk_day2 = strtotime($new_start);
$date_day2 = date("Y-m-d",strtotime("+1 days",$wk_day2));
$week_day2 = "Tue";//551
//wednesday
$wk_day3 = strtotime($new_start);
$date_day3 = date("Y-m-d",strtotime("+2 days",$wk_day3));
$week_day3 = "Wed";//552
//thursday
$wk_day4 = strtotime($new_start);
$date_day4 = date("Y-m-d",strtotime("+3 days",$wk_day4));
$week_day4 = "Thu";//553
//friday
$wk_day5 = strtotime($new_start);
$date_day5 = date("Y-m-d",strtotime("+4 days",$wk_day5));
$week_day5 = "Fri";//554
//saturday
$wk_day6 = strtotime($new_start);
$date_day6 = date("Y-m-d",strtotime("+5 days",$wk_day6));
$week_day6 = "Sat";//555
//sunday
$wk_day7 = strtotime($new_start);
$month_day7 = date("F d",strtotime("+6 days",$wk_day7));
$date_day7 = date("Y-m-d",strtotime("+6 days",$wk_day7));
$week_day7 = "Sun";//556
/************************configuration*************************/
$add_time = 900; //15 min appointment time interval
$start_time = "08:00:00";
$end_time = "16:00:00";
$status = A;
/*************** this section displays the appointments***********/
//search area display area layer and …
assgar 14 Junior Poster in Training
Hi
Thanks for the response.
This is the solution.
I have left the echos for testing:this displays what is occuring.
<?
//for spliting date range into three: range 1 end date (- one day gives prevoius day)
$old_sec = strtotime($old_start_date);
$new_sec = strtotime($new_start_date);
$diff_day = floor((($new_sec - $old_sec) - 86400)/86400);
$mod_end = date("Y-m-d", strtotime("+$diff_day days",$old_sec));
//for spliting date range into three: range 3 start date (+ one day gives next day)
$end_sec = strtotime($new_end_date);
$start_sec = strtotime($new_start_date);
$diff_day = floor(((($end_sec - $start_sec)) + 86400)/86400);
$mod_start = date("Y-m-d", strtotime("+$diff_day days",$start_sec));
//same dates
if($new_start_date == $old_start_date && $new_end_date == $old_end_date)
{
echo "(date)==== <br>";
if($new_start_time == $old_start_time && $new_end_time == $old_end_time)
{
$update_start_time = $new_start_time;
$update_end_time = $new_end_time;
$update_start_date = $new_start_date;
$update_end_date = $new_end_date;
$update_type = $new_type;
echo "(time)==== <br>";
$action = 1;
}
elseif($new_start_time > $old_start_time && $new_end_time == $old_end_time)
{
$update_start_time = $old_start_time;
$update_end_time = $new_start_time;
$update_start_date = $old_start_date;
$update_end_date = $new_end_date;
$update_type = $old_type;
$insert1_start_time = $new_start_time;
$insert1_end_time = $new_end_time;
$insert1_start_date = $new_start_date;
$insert1_end_date = $new_end_date;
$insert1_type = $new_type;
echo "(time)>== <br>";
$action = 2;
}
elseif($new_start_time == $old_start_time && $new_end_time < $old_end_time)
{
$update_start_time = $new_end_time;
$update_end_time = $old_end_time;
$update_start_date = $old_start_date;
$update_end_date = $new_end_date;
$update_type = $old_type;
$insert1_start_time = $new_start_time;
$insert1_end_time = $new_end_time;
$insert1_start_date = $new_start_date;
$insert1_end_date = $new_end_date;
$insert1_type = $new_type;
echo "(time)==< <br>";
$action = 2;
}
elseif($new_start_time > $old_start_time && $new_end_time < $old_end_time)
{
$update_start_time = $old_start_time;
$update_end_time = $new_start_time;
$update_start_date = $new_start_date;
$update_end_date = $new_end_date;
$update_type = $old_type;
$insert1_start_time = …
assgar 14 Junior Poster in Training
Hi
Thanks for the response. This is the solution I arrived at.
I am open to changing it
<?php
/**NOTE:
Where editing of time/date range is between existing start and end time/date range.
The existing range is split into 3 portions: beginning (update), middle (insert1)
and end (insert2).
update:
a)time: use existing time range,
b)date: existing start to new start date(insert1) minus 1 (previous day)
insert1:
a)time: new time range
b)date: new date range
insert2:
a)time: use existing time range
b)date: new end date plus 1 (following day) to existing end date
//edited time range is before/after existing end time range
update:
a)time: use existing time range,
b)date: existing start to edition(insert1) start date minus 1 (previous day)
insert1:
a)time: new
b)date: new
**/
/**-----------------------variables--------------------------**/
//table data being edited:
$old_start_date = "2008-01-01";
$old_end_date = "2008-01-10";
$old_type = 201;
$old_start_time = "09:00:00";
$old_end_time = "12:00:00";
//selected from current form:
$new_start_date = "2008-01-01";
$new_end_date = "2008-01-04';
$new_type = 202;
$new_start_time = "10:00:00";
$new_end_time = "11:00:00";
/**--------------values for update and insert query---------------**/
//for spliting date range into three: range 1 end date (- one day gives prevoius day)
$old_sec = strtotime($old_start_date);
$new_sec = strtotime($new_start_date);
$diff_day = floor((($new_sec - $old_sec) - 86400)/86400);
$mod_end = date("Y-m-d", strtotime("+$diff_day days",$old_sec));
//for spliting date range into three: range 3 start date (+ one day gives next day)
$end_sec = strtotime($new_end_date);
$start_sec = strtotime($new_start_date);
$diff_day = floor(((($end_sec - $start_sec)) + 86400)/86400);
$mod_start = date("Y-m-d", strtotime("+$diff_day days",$start_sec));
if($new_start_date == $old_start_date && $new_end_date == $old_end_date &&
$new_start_time == $old_start_time …
assgar 14 Junior Poster in Training
Hi
After some time I think I have done it.
Let nme know if you have any suggestions how to refine the code.
The result below is for a three week (7 day) cycle for the month of January.
Note: week days Monday (550) to Friday (554)
Result Columns:
date range(start date, end date), day of week, time range(start time and end time)
inner loop)1
2008-01-01 2008-01-07 550 09:00:00 12:00:00
2008-01-22 2008-01-28 550 09:00:00 12:00:00
2008-01-01 2008-01-07 551 09:00:00 12:00:00
2008-01-22 2008-01-28 551 09:00:00 12:00:00
2008-01-01 2008-01-07 552 09:00:00 12:00:00
2008-01-22 2008-01-28 552 09:00:00 12:00:00
2008-01-01 2008-01-07 553 09:00:00 12:00:00
2008-01-22 2008-01-28 553 09:00:00 12:00:00
2008-01-01 2008-01-07 554 09:00:00 12:00:00
2008-01-22 2008-01-28 554 09:00:00 12:00:00
(inner loop)2
2008-01-08 2008-01-14 550 10:00:00 13:00:00
2008-01-29 2008-01-31 550 10:00:00 13:00:00
2008-01-08 2008-01-14 551 10:00:00 13:00:00
2008-01-29 2008-01-31 551 10:00:00 13:00:00
2008-01-08 2008-01-14 552 10:00:00 13:00:00
2008-01-29 2008-01-31 552 10:00:00 13:00:00
2008-01-08 2008-01-14 553 10:00:00 13:00:00
2008-01-29 2008-01-31 553 10:00:00 13:00:00
2008-01-08 2008-01-14 554 10:00:00 13:00:00
2008-01-29 2008-01-31 554 10:00:00 13:00:00
(inner loop)3
2008-01-15 2008-01-21 550 16:00:00 20:00:00
2008-01-15 2008-01-21 551 16:00:00 20:00:00
2008-01-15 2008-01-21 552 16:00:00 20:00:00
2008-01-15 2008-01-21 553 16:00:00 20:00:00
2008-01-15 2008-01-21 554 16:00:00 20:00:00
<?
$max_week = '3';
$start_date = '2008-01-01';
$end_date = '2008-01-31';
/**-------------loop through number of weeks------------**/
for($i = 1; $i <= $max_week; $i++) …
assgar 14 Junior Poster in Training
Hi
I am having problems how to proceed in editing appointment info.
In this example I have a meeting (code 201) on Monday (day code 550)
from 09:00:00 to 12:00:00.
This is stored in the data table as:
start_time end_time start_date end_date week_day type_code
09:00:00 12:00:00 2008-01-01 2008-01-01 550 201
If I decided need to change the time range for the appointments to
meeting 09:00 to 10:00, break 10:00 to 11:00 and meeting 11:00 to 12:00.
What is the best way to edit the data table to refelect that I am taking a
break from 10:00 to 11:00?
1) I am having trouble determining how to extract the 10:00 to 11:00 time range from the
existing 09:00 to 12:00 time range found in the data table to get these results.
start_time end_time start_date end_date week_day type_code
09:00:00 10:00:00 2008-01-01 2008-01-01 550 201
10:00:00 11:00:00 2008-01-01 2008-01-01 550 202
11:00:00 12:00:00 2008-01-01 2008-01-01 550 201
2) To get the above results should I copy the existing data and insert
two new entries (10 to 11 and 11 to 12) and update the existing entry to reflect 9 to 10?
3) What formulas/functions can I use to allow changes to any part of the time range?
Note: This is a dynamic system.
Appointment time is displayed in 15 minute interval usiing the start and end time
…
assgar 14 Junior Poster in Training
Hi
After some time I think I have done it.
Let nme know if you have any suggestions how to refine the code.
The result below is for a three week (7 day) cycle for the month of January.
Note: week days Monday (550) to Friday (554)
Result Columns:
date range(start date, end date), day of week, time range(start time and end time)
inner loop)1
2008-01-01 2008-01-07 550 09:00:00 12:00:00
2008-01-22 2008-01-28 550 09:00:00 12:00:00
2008-01-01 2008-01-07 551 09:00:00 12:00:00
2008-01-22 2008-01-28 551 09:00:00 12:00:00
2008-01-01 2008-01-07 552 09:00:00 12:00:00
2008-01-22 2008-01-28 552 09:00:00 12:00:00
2008-01-01 2008-01-07 553 09:00:00 12:00:00
2008-01-22 2008-01-28 553 09:00:00 12:00:00
2008-01-01 2008-01-07 554 09:00:00 12:00:00
2008-01-22 2008-01-28 554 09:00:00 12:00:00
(inner loop)2
2008-01-08 2008-01-14 550 10:00:00 13:00:00
2008-01-29 2008-01-31 550 10:00:00 13:00:00
2008-01-08 2008-01-14 551 10:00:00 13:00:00
2008-01-29 2008-01-31 551 10:00:00 13:00:00
2008-01-08 2008-01-14 552 10:00:00 13:00:00
2008-01-29 2008-01-31 552 10:00:00 13:00:00
2008-01-08 2008-01-14 553 10:00:00 13:00:00
2008-01-29 2008-01-31 553 10:00:00 13:00:00
2008-01-08 2008-01-14 554 10:00:00 13:00:00
2008-01-29 2008-01-31 554 10:00:00 13:00:00
(inner loop)3
2008-01-15 2008-01-21 550 16:00:00 20:00:00
2008-01-15 2008-01-21 551 16:00:00 20:00:00
2008-01-15 2008-01-21 552 16:00:00 20:00:00
2008-01-15 2008-01-21 553 16:00:00 20:00:00
2008-01-15 2008-01-21 554 16:00:00 20:00:00
<?
$max_week = '3';
$start_date = '2008-01-01';
$end_date = '2008-01-31';
/**-------------loop through number of weeks------------**/
for($i = 1; $i <= $max_week; $i++) …
assgar 14 Junior Poster in Training
Thanks great solution.
assgar 14 Junior Poster in Training
Hi
I am trying to increment the date using weekly increments.
I need to determine the start and end dates and the week number of the year.
If you can suggest another approache that is OK, but this is what I came up with.
I am having problems getting the correct increment and week number of the year.
result received:
(week number) 01-1
(next start) 1970-01-07
(next end) 1970-01-07
result expected:
(week number) 02
(next start) 2008-02-14
(next end) 2008-02-21
<?
$week number = 1;//the for loop increment number
$week cycle = 2;//This will provide the date for the 1st, 2nd, 3rd or 4th week of the month.
$start_date = "2008-02-01";
$nw = ($week number * $week cycle) + 1;//+ 1 to be in the next range
$next_start = date("Y-m-d",strtotime("+$nw week", $start_date));
$next_end = date('Y-m-d',strtotime("+1 week", $next_start))."<br>";
$week_number = date('W', $next_start);//week number of the year
?>
assgar 14 Junior Poster in Training
Hi
I need help.
I know what I want to accomplish, but I do not know how to do it.
The events are recurring every month, but not recurring at the same time or on the same day of the week.
WHAT I NEED HELP ACCOMPLISHING:
How to do I insert recurring events into a table for a date range.
Where the months are the same but the event/appointment types occur at different
times and or on different days of the week.
POSSIBLE APPROACH:
I would like to choose a 7 day cycle/template, or to allow making the weeks
different with a 14 day or 21 day or 28 day cycle/template.
For example the 14 days cycle represents two weeks where every second week can be different.
Day# Day
1
2 Monday (meetings 1:00pm to 3:00pm)
3 Tuesday
4 Wednesday
5 Thursday (breakfast meeting 8:00AM to 9:00AM)
6 Friday
7
8
9 Monday (breakfast meeting 8:00AM to 9:00AM)
10 Tuesday
11 Wednesday (meetings 1:00pm to 3:00pm)
12 Thursday
13 Friday
14
The current code works well for a week or if every week is the same in the date range.
See below.
The availablity table store different event/appointment types using date and time range.
This event/appointment type information is then displayed to the user …
assgar 14 Junior Poster in Training
Hi
I need help.
I know what I want to accomplish, but I do not know how to do it.
The events are recurring every month, but not recurring at the same time or on the
same day of the week.
WHAT I NEED HELP ACCOMPLISHING:
How to do I insert recurring events into a table for a date range.
Where the months are the same but the event/appointment types occur at different
times and or on different days of the week.
POSSIBLE APPROACH:
I would like to choose a 7 day cycle/template, or to allow making the weeks
different with a 14 day or 21 day or 28 day cycle/template.
For example the 14 days cycle represents two weeks where every second week can be
different.
Day# Day
1
2 Monday (meetings 1:00pm to 3:00pm)
3 Tuesday
4 Wednesday
5 Thursday (breakfast meeting 8:00AM to 9:00AM)
6 Friday
7
8
9 Monday (breakfast meeting 8:00AM to 9:00AM)
10 Tuesday
11 Wednesday (meetings 1:00pm to 3:00pm)
12 Thursday
13 Friday
14
The current code works well for a week or if every week is the same in the date range.
See below.
The availablity table store different event/appointment types using date and time range.
This event/appointment type information is then displayed to …
assgar 14 Junior Poster in Training
Hi
I need help.
I know what I want to accomplish, but I do not know how to do it.
WHAT I NEED HELP ACCOMPLISHING:
How to do I insert data into a table for a date range of two or more months,
where every second or third week should be able to have different events/appointments.
POSSIBLE APPROACH:
I would like to choose a 7 day cycle/template, or to allow making the weeks
different with a 14 day or 21 day or 28 day cycle/template.
For example the 14 days cycle represents two weeks where every second week can be different.
Day# Day
1
2 Monday (meetings 1:00pm to 3:00pm)
3 Tuesday
4 Wednesday
5 Thursday (breakfast meeting 8:00AM to 9:00AM)
6 Friday
7
8
9 Monday (breakfast meeting 8:00AM to 9:00AM)
10 Tuesday
11 Wednesday (meetings 1:00pm to 3:00pm)
12 Thursday
13 Friday
14
The current code works well for a week or if every week is the same in the date range.
See below.
The availablity table store different event/appointment types using date and time range.
This event/appointment type information is then displayed to the user using a daily
schedule format.
HOW THE 7 DAY CYCLE DATA IS STORED:
Example: Meetings(event_type_code) between 2:30 PM and 4:30 PM for Monday to Friday
this is stored …
assgar 14 Junior Poster in Training
I am having problem with my loping.
I don't know if I have chosen the correct approach.
GOAL:
I need to insert into a table event types for a specific date range.
The calendar the event type is displayed on is divided into
15 minutes time intervals
A group consist of days of the week, each day consist of segments of
time blocks for different events:
Note:
The day segments are stored in a table linked to the group_id foreign key
Group
-------------------------------------------------------------------------
| Group Days| Day Segments |Event Type |# of 15 min blocks|
| ---------------------------------------|-----------|------------------|
| Monday |09:00 to 12:00 appointment | 201 | 12 |
|----------------------------------------|-----------|------------------|
| Tuesday |09:00 to 12:00 appointment | 201 | 12 |
| |01:00 to 04:00 appointment | 201 | 12 |
|----------------------------------------|-----------|------------------|
| Wednesday |09:00 to 12:00 appointment | 201 | 12 |
| |01:00 to 04:00 appointment | 201 | 12 |
|----------------------------------------|-----------|------------------|
| Thursday |09:00 to 12:00 appointment | 201 | 12 |
| |01:00 to 04:00 Lunch | 201 | 12 |
|----------------------------------------|-----------|------------------|
| Friday |05:00 to 08:00 appointment | 201 | 12 |
| |09:00 to 10:00 appointment | 201 | 4 |
|----------------------------------------|-----------|------------------|
| Saturday |09:00 to 12:00 appointment | 201 | 12 |
| |01:00 to 04:00 appointment | 201 | 12 |
…
assgar 14 Junior Poster in Training
Hi
Thanks for the suggestion.
This is the final code that solved the problem
<?
$event_time = 09:00:00
$event_length = 15;
$timestamp = strtotime("$event_time");
$etime = strtotime("+$event_length minutes", $timestamp);
$next_time = date('H:i:s', $etime);
?>
assgar 14 Junior Poster in Training
Hi
How can I add 15 minutes to the previous event time (timestamp) to get the next event time.
Note: This event time is not in a table.
Straight forward adding the two values will probly not provide the correct result.
I can get the correct time with Mysql addtime($time, $duration) but that
is only good if the if info is in a table.
Thanks
<?php
$time = "09:00:00";//timestamp hh:mm:ss
$duration = 00:15:00;//enent duration hh:mm:ss
$next_time = $event_time + $event_duration;
?>
assgar 14 Junior Poster in Training
Thanks for the response.
You were right the table height was the issue.
assgar 14 Junior Poster in Training
Hi
I am having a problem with the height of my dynamically create rows.
The data is retrived properly form the database, the issue is displaying the rows.
When there are alot of results to dusplay the rows are displayed correctly.
If there are a few rows the hight can be 3 times the height as when there alot of rows.
Note: Below is a simplified version of the code.
<?php
$query = "SELECT event_id, event_date, event_time
FROM cal_appointment
WHERE status = 'A'
ORDER BY event_date, event_time";
$result = mysqli_query($mysqli, $query) or die('Error, query failed');
/************************ this section displays the events*************************/
echo "<table width=\"100%\" border=\"0\">";
echo"<tr align=\"center\" bgcolor=\"#FFFFFF\">";
echo" <td width=\"100%\" >
<div id=\"Layer2\" style=\"position:absolute; width:100%; height:100px; z-index:2; left: 8px; top: 310px;\">
<div id=\"scroll-box2\" style=\"overflow: auto; float: left; width: 100%; height: 240px; margin: 5px; \">\n";
//table begins
echo "<table width=\"98%\" height=\"310\" left =\"4\" border=\"0\" font face =\"arial\">\n";
$result = mysqli_query($mysqli,$query) or die('Error, query failed');
$num_rows = mysqli_num_rows($result);
for($i=0; $i < $num_rows; $i++)
{
$row = mysqli_fetch_array($result);
list($event_id, $event_date, $event_time) = $row;
/**convert 24hr time to 12 hr**/
list($hour, $min, $sec) = split(":",$event_time);
if($hour > 12)
{
$time_hour = $hour - 12;
}
else
{
$time_hour = $hour;
}
//format time of day
if($hour < 12)
{
$tod = "AM";
}
else
{
$tod = "PM";
}
$time = "$hour:$min $tod";
echo "<tr>";
echo"<td width=\"18%\" height=\"15\" align=\"center\">$time</td>
<td width=\"12%\" height=\"15\">$event_date</td>\n";
echo "</tr>";
}//end for
echo "</table>";
echo "</td>";
echo "</tr>";
echo "</div>";
echo "</div>";
echo "</table>"; …