PHP/MySQL - 调度调度器 - 垂直列 [英] PHP/MySQL - Dispatch Scheduler - Vertical Column
问题描述
我正在编写一个应用程序,需要在垂直列结构中显示销售员的约会.我能找到的最接近的东西可以很好地处理我想做的事情:
销售人员的名字在上面,他们一周的约会是垂直安排的.销售员有约会的每一天(在本例中为星期四和星期五)还有一个漂亮的蓝色标题.
这是我的 MySQL APPOINTMENTS
表的设置方式:任命表:
======================================================================身份证 |id_sales |id_lead |appt_date |appt_time |----------------------------------------------------------------------1 |1 |2 |2013-12-26 |11:00 |----------------------------------------------------------------------2 |1 |3 |2013-01-05 |13:00 |----------------------------------------------------------------------3 |2 |5 |2013-12-27 |13:00 |----------------------------------------------------------------------4 |2 |6 |2013-12-28 |17:00 |----------------------------------------------------------------------5 |1 |7 |2013-12-29 |19:30 |======================================================================
id_sales
指的是销售员的个人 ID(在另一个表中处理),id_lead
指的是约会(也在另一个表中处理).
截至目前,我不需要完整解释如何处理此任务的各个方面.我被卡住了,不知道如何继续.我很乐意将销售人员的 ID 作为表格标题,在它们下面带有约会 ID (id_lead
).在您的帮助下,我会在完成该作品后尝试找出其余部分;)
我将附上我想出的非工作代码:
schedule.php:
<代码>...<div id="schedule_wrapper_all"><?php print get_schedule_all();?>
...
db_functions.php:
function get_schedule_all() {$headers = get_table_headers();$schedule_builder = '';$schedule_builder .= '';$schedule_builder .= $headers;$schedule_builder .='
';返回 $schedule_builder;}函数 get_table_headers() {包括脚本/mysql_login_pdo.php";$query = "SELECT DISTINCT `id_sales` FROM `appointments` ORDER BY `id_sales` ASC";$stmt = $db->prepare($query);$stmt->execute();$约会 = '';$schedule_headers = '';$schedule_headers .='';while ($row = $stmt->fetchObject()) {$id_sales = $row->id_sales;$schedule_headers .= "$id_sales ";$appointments .= fill_appts($id_sales);}$schedule_headers .= '</tr>';$db = 空;$schedule_headers .= $appointments;返回 $schedule_headers;}函数 fill_appts($id_sales) {包括脚本/mysql_login_pdo.php";$query = "SELECT `id_lead` FROM `appointments` WHERE `id_sales` = :id_sales";$stmt = $db->prepare($query);$stmt->执行(数组(':id_sales' =>$id_sales));$schedule_appts = '';$schedule_appts .=' ';while ($row = $stmt->fetchObject()) {$id_lead = $row->id_lead;$schedule_appts .= "$id_lead ";}$schedule_appts .= '</tr>';$db = 空;返回 $schedule_appts;}结果截图:
再次感谢您的帮助!
-------------------------------------------更新-----------------------------------------
得到它的工作.需要很多样式,但这是朝着正确方向的开始.
function get_schedule_all() {$headers = get_table_headers();$约会 = 约会();$schedule_builder = '';$schedule_builder .='';$schedule_builder .= $headers;$schedule_builder .= $appointments;$schedule_builder .='
';返回 $schedule_builder;}函数 get_table_headers() {包括脚本/mysql_login_pdo.php";$query = "SELECT DISTINCT `id_sales` FROM `appointments` ORDER BY `id_sales` ASC";$stmt = $db->prepare($query);$stmt->execute();$schedule_headers = '';$schedule_headers .='';while ($row = $stmt->fetchObject()) {$id_sales = $row->id_sales;$schedule_headers .= "<td id='$id_sales'>$id_sales</td>";}$schedule_headers .= '</tr>';$db = 空;返回 $schedule_headers;}函数 fill_appts($id_sales) {包括脚本/mysql_login_pdo.php";$query = "SELECT `id_lead` FROM `appointments` WHERE `id_sales` = :id_sales";$stmt = $db->prepare($query);$stmt->执行(数组(':id_sales' =>$id_sales));$schedule_appts = '';$schedule_appts .='';while ($row = $stmt->fetchObject()) {$id_lead = $row->id_lead;$schedule_appts .= "<tr><td class='appt'>$id_lead</td></tr>";}$schedule_appts .='
';$db = 空;返回 $schedule_appts;}函数约会(){包括脚本/mysql_login_pdo.php";$query = "SELECT DISTINCT `id_sales` FROM `appointments` ORDER BY `id_sales` ASC";$stmt = $db->prepare($query);$stmt->execute();$约会 = '';$appointments .=' ';while ($row = $stmt->fetchObject()) {$id_sales = $row->id_sales;$appointments .='';$appointments .= fill_appts($id_sales);$appointments .=' ';}$约会.= '</tr>';$db = 空;返回 $appointments;} 解决方案 你能做的就是代替$id_lead
,创建另一个; 在 id sales 的每个单元格内,然后使用 $id_lead
这样每个 $id_lead 将是下面的一行id_sales.这样你就会有 2,3 和 7 作为表格中的 3 行,位于 id_sales 1 的单元格内.而 5,6 作为表格中的 2 行,位于 id_sales 2 的单元格内.
I am writing an application that needs to show appointments for salesman in a vertical column structure. The closest thing I can find that would handle what I want to do nicely looks like this:
The salesmen's names are on top, and their appointments for the week are scheduled vertically. There is also a nice blue heading for each day the salesman has an appointment (Thursday and Friday in this example).
This is how my MySQL APPOINTMENTS
table is setup:
APPOINTMENTS Table:
======================================================================
id | id_sales | id_lead | appt_date | appt_time |
----------------------------------------------------------------------
1 | 1 | 2 | 2013-12-26 | 11:00 |
----------------------------------------------------------------------
2 | 1 | 3 | 2013-01-05 | 13:00 |
----------------------------------------------------------------------
3 | 2 | 5 | 2013-12-27 | 13:00 |
----------------------------------------------------------------------
4 | 2 | 6 | 2013-12-28 | 17:00 |
----------------------------------------------------------------------
5 | 1 | 7 | 2013-12-29 | 19:30 |
======================================================================
id_sales
refers to the salesmen's individual ID's (handled in another table) and id_lead
refers to the appointments (also handled in another table).
As of right now, I don't need a complete explanation of how to handle every aspect of this task. I am stuck, and don't know how to proceed. I would be happy enough to get the salesmen's ID's as table headers, with the appointment id's (id_lead
) underneath them. I will try to figure out the rest once I get that piece working, with your help ;)
I will attach the non-working code I have come up with:
schedule.php:
...
<div id="schedule_wrapper_all">
<?php print get_schedule_all(); ?>
</div>
...
db_functions.php:
function get_schedule_all() {
$headers = get_table_headers();
$schedule_builder = '';
$schedule_builder .= '<table border="1">';
$schedule_builder .= $headers;
$schedule_builder .= '</table>';
return $schedule_builder;
}
function get_table_headers() {
include 'scripts/mysql_login_pdo.php';
$query = "SELECT DISTINCT `id_sales` FROM `appointments` ORDER BY `id_sales` ASC";
$stmt = $db->prepare($query);
$stmt->execute();
$appointments = '';
$schedule_headers = '';
$schedule_headers .= '<tr>';
while ($row = $stmt->fetchObject()) {
$id_sales = $row->id_sales;
$schedule_headers .= "<th id='$id_sales'>$id_sales</th>";
$appointments .= fill_appts($id_sales);
}
$schedule_headers .= '</tr>';
$db = null;
$schedule_headers .= $appointments;
return $schedule_headers;
}
function fill_appts($id_sales) {
include 'scripts/mysql_login_pdo.php';
$query = "SELECT `id_lead` FROM `appointments` WHERE `id_sales` = :id_sales";
$stmt = $db->prepare($query);
$stmt->execute(array(
':id_sales' => $id_sales
));
$schedule_appts = '';
$schedule_appts .= '<tr>';
while ($row = $stmt->fetchObject()) {
$id_lead = $row->id_lead;
$schedule_appts .= "<td>$id_lead</td>";
}
$schedule_appts .= '</tr>';
$db = null;
return $schedule_appts;
}
Screenshot of result:
Thanks again for any help!
------------------------------------------UPDATE----------------------------------------
Got it working. Needs a lot of styling, but it's a start in the right direction.
function get_schedule_all() {
$headers = get_table_headers();
$appointments = appointments();
$schedule_builder = '';
$schedule_builder .= '<table>';
$schedule_builder .= $headers;
$schedule_builder .= $appointments;
$schedule_builder .= '</table>';
return $schedule_builder;
}
function get_table_headers() {
include 'scripts/mysql_login_pdo.php';
$query = "SELECT DISTINCT `id_sales` FROM `appointments` ORDER BY `id_sales` ASC";
$stmt = $db->prepare($query);
$stmt->execute();
$schedule_headers = '';
$schedule_headers .= '<tr>';
while ($row = $stmt->fetchObject()) {
$id_sales = $row->id_sales;
$schedule_headers .= "<td id='$id_sales'>$id_sales</td>";
}
$schedule_headers .= '</tr>';
$db = null;
return $schedule_headers;
}
function fill_appts($id_sales) {
include 'scripts/mysql_login_pdo.php';
$query = "SELECT `id_lead` FROM `appointments` WHERE `id_sales` = :id_sales";
$stmt = $db->prepare($query);
$stmt->execute(array(
':id_sales' => $id_sales
));
$schedule_appts = '';
$schedule_appts .= '<table>';
while ($row = $stmt->fetchObject()) {
$id_lead = $row->id_lead;
$schedule_appts .= "<tr><td class='appt'>$id_lead</td></tr>";
}
$schedule_appts .= '</table>';
$db = null;
return $schedule_appts;
}
function appointments(){
include 'scripts/mysql_login_pdo.php';
$query = "SELECT DISTINCT `id_sales` FROM `appointments` ORDER BY `id_sales` ASC";
$stmt = $db->prepare($query);
$stmt->execute();
$appointments = '';
$appointments .= '<tr>';
while ($row = $stmt->fetchObject()) {
$id_sales = $row->id_sales;
$appointments .= '<td>';
$appointments .= fill_appts($id_sales);
$appointments .= '</td>';
}
$appointments .= '</tr>';
$db = null;
return $appointments;
}
解决方案 what you can do is instead of <td>$id_lead</td>
, create another <table>
inside each cell of id sales and then use <tr><td>$id_lead</td></tr>
that way each $id_lead will be a row below id_sales.
That way you'll have 2,3,and 7 as 3 rows in a table, inside the cell of id_sales 1. And 5,6 as 2 rows in a table, inside the cell of id_sales 2.
这篇关于PHP/MySQL - 调度调度器 - 垂直列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文
登录
关闭
扫码关注1秒登录
发送“验证码”获取
|
15天全站免登陆