Correohs
-
Posts
2 -
Joined
-
Last visited
Posts posted by Correohs
-
-
Help needed.
I have 3 domains pointing same directory in my webserver (ISP)
mysite.com
mysite.net
mysite.info
I wanted to use (1) one menu file for all of them, that I load it to the include subfolder.
mywebsite structure
/index.php ( I use include $_SERVER['DOCUMENT_ROOT']."/include/menu.html"; )
/about.php ( I use include $_SERVER['DOCUMENT_ROOT']."/include/menu.html"; )
/contactus.php ( I use include $_SERVER['DOCUMENT_ROOT']."/include/menu.html"; )
/(more files) ( I use include $_SERVER['DOCUMENT_ROOT']."/include/menu.html"; )
/link/
/link/index.php ( I use include $_SERVER['DOCUMENT_ROOT']."/include/menu.html"; )
/link/(more php files) ( I use include $_SERVER['DOCUMENT_ROOT']."/include/menu.html"; )
/include
/include/menu.html
Menu File Structure
<li><a href="aboutus.php">ABOUT</a>
<ul><li><a href="aboutus.php">ABOUT US</a></li>
<li><a href="contactus.php">CONTACT US</a></li>
<li><a href="testimonial.html">GUEST BOOK</a></li>
</ul>
</li>
from my php application I use
include $_SERVER['DOCUMENT_ROOT']."/include/menu.html";
Pages on root directory are working well.
/aboutus.php
/contactus.php
/testimonial.html
when I'm on /link directory (subfolder )I got problems
the menu will point to.
/link/aboutus.php
/link/contactus.php
/link/testimonial.html
Getting page no found.
if I'm in a subfolder, how can I do to call the include file, and preserver the root path automatically.
---- let me try to make simpler ----
3 mysites domain
mysite.com mysite.net mysite.info
.com .net .info
/
/index.php
/about.php
/contactus.php
/testimonial.html
/(more files)
/link/
/link/index.php
/link/(more php files)
/include/menu.html
How can I call /include/menu.html from any directory level and maintain same behavior?
------
Thanks!
CorreoHS
Retrieve data from Table1/2/3/4, display data, cannot save it in Table5
in PHP Coding Help
Posted
I'm working in a system. Retrieve info using LEFT JOIN and I'd like to save this info in another table. passing those variable using $_POST
I want to display $act_id_numb ( Activity ID Number ) passing to save.php page. to INSERT it to the table.
in 3 days I coudnt figure that out. Any help its really apreciate it. Thanks in Advance! Angel.
System retrieve some info from database and display it. to add a new record system open a new windows. and bring even more info from DB. when I try to save it. the sytem loose some info. 1- its because I dont know how to send a $act_id_numb to the Save page using $_POST it should be $_POST [ 'act_id_numb']
how can I convert form $act_id_numb to act_id_numb ( with no $ sign )
System Idea is Employees are working for Clients doing different job for them, I want to track the time that each employee spend with the Client and if there was a Power Outage be able to know about it.
Image01 - retrieve data from DB ( upload it using phpmyadmin into to tbl_Layout.
Image02 - I want to add a new record. but I coudnt make it to work.
You can see te.php , get_te.php, save_te.php ( just for new records )
Thanks!
---------
te.php
---------
<script type="text/javascript" src="http://code.jquery.c...n.js"></script>
<script type="text/javascript" src="http://www.jeasyui.c...n.js"></script>
<script type="text/javascript">
var url;
function newUser(){
$('#dlg').dialog('open').dialog('setTitle','New Activity');
$('#fm').form('clear');
url = 'save_te.php';
}
function editUser(){
var row = $('#dg').datagrid('getSelected');
if (row){
$('#dlg').dialog('open').dialog('setTitle','Edit');
$('#fm').form('load',row);
url = 'update_te.php?id='+row.id;
}
}
function saveUser(){
$('#fm').form('submit',{
url: url,
onsubmit: function(){
return $(this).form('validate');
},
success: function(result){
var result = eval('('+result+')');
if (result.success){
$('#dlg').dialog('close'); // close the dialog
$('#dg').datagrid('reload'); // reload the user data
} else {
$.messager.show({
title: 'Error',
msg: result.msg
});
}
}
});
}
function removeUser(){
var row = $('#dg').datagrid('getSelected');
if (row){
$.messager.confirm('Confirm','Are you sure?',function®{
if ®{
$.post('remove_te.php',{emp_id:row.emp_id},function(result){
if (result.success){
$('#dg').datagrid('reload'); // reload the user data
} else {
$.messager.show({ // show error message
title: 'Error',
msg: result.msg
});
}
},'json');
}
});
}
}
</script>
</head>
<body>
<?php include 'conn.php'; ?>
<h2 align="center"><a href="index.php">Main Menu </a></h2>
<div class=container>
<h2 style="text-align: left;">TEMS 2013 [ C.R.U.D.]</h2>
<div class="demo-info" style="margin-bottom:10px">
<div class="demo-tip icon-tip"> </div>
<div>Click the buttons on datagrid toolbar to do crud actions.</div>
</div>
<table id="dg" title="TEMS Activities" class="easyui-datagrid" style="width:900px;height:350px"
url="get_te.php"
toolbar="#toolbar" pagination="true"
rownumbers="true" fitColumns="true" singleSelect="true">
<thead>
<tr>
<th align="center" field="lo_id">Rec.</th>
<th field="lo_client_id">Client #</th>
<th align="center" field="client_desc">Name</th>
<th align="center" field="lo_empl_id">Empl #</th>
<th field="emp_last_name"> Firt N.</th>
<th field="emp_first_name"> Last N.</th>
<th align="center" field = "lo_act_id"> Act.# </th>
<th align="center" field = "act_id_numb"> Act.2 </th>
<th field = "act_desc"> Desc.</th>
<th align="center" field="lo_time"> Time </th>
<th field = "lo_desc"> Cause </th>
<th field="m_desc"> Month</th>
<th field="lo_year"> Year</th>
</tr>
</thead>
</table>
<div id="toolbar">
<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">New</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">Edit</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="removeUser()">Remove</a>
</div>
<div id="dlg" class="easyui-dialog" style="width:600px;height:480px;padding:10px 20px"
closed="true" buttons="#dlg-buttons">
<div class="ftitle">Information</div>
<form id="fm" method="post" novalidate>
<?php // --------- Form Start ---------------- ?>
<div class="fitem">
<?php
include 'conn.php';
$sqlc = "SELECT client_desc,client_code FROM tbl_Client";
$resultc = mysql_query($sqlc);
echo "<select name='lo_client_id'>";
echo "<OPTION selected>--Select--</OPTION>";
while ($rowc = mysql_fetch_array($resultc)) {
echo "<option value='" . $rowc['client_code'] . "'>" . $rowc['client_desc'] . " - ".$rowc['client_code'] . "</option>";
}
echo "</select>";
?>
</div>
<div class="fitem">
<?php
$sql1 = "SELECT emp_code, emp_last_name,emp_first_name FROM tbl_Employee";
$result1 = mysql_query($sql1);
echo "<select name='lo_empl_id'>";
echo "<OPTION selected>--Select--</OPTION>";
while ($row1 = mysql_fetch_array($result1)) {
echo "<option value='" . $row1['emp_code'] . "'>" . $row1['emp_last_name']. ", ".$row1['emp_first_name'] . "</option>";
}
echo "</select>";
?>
</div>
<div class="fitem">
<select name="lo_month" size="1">
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select name="lo_year" size="1">
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
</select>
</div>
<div class="fitem">
<?php
$sql_act = "SELECT * FROM tbl_Activ where act_id_numb=$lo_act_id ORDER BY act_title_id_numb";
$result_act = mysql_query($sql_act);
?>
<br>
<table id="tb" cellspacing="0">
<thead><tr><th>Title ID</th><th>Act ID</th><th>Desc</th><th>Time</th></tr></thead>
<tbody>
<?php
while ($row_act = mysql_fetch_array($result_act)) {
$act_title_id_numb = $row_act['act_title_id_numb'];
$act_id_numb = $row_act['act_id_numb'];
$act_desc = $row_act['act_desc'];
echo '<tr>';
echo
'<td align="right"><b>' . $act_title_id_numb . '</b></td>' .
'<td align="right">' . $act_id_numb . '</td>' .
'<td class="even">' . $act_desc . '</td>';
?>
<?php
echo '</tr>';
}
?>
</tbody>
</table>
</div>
</div>
<?php // --------- Form End ------------- ?>
</form>
</div>
<div id="dlg-buttons">
<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveUser()">Save</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">Cancel</a>
</div>
</div>
</body>
</html>
--------------
get_te.php
--------------
<?php
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$offset = ($page-1)*$rows;
$result = array();
include 'conn.php';
$rs = mysql_query("select count(*) from tbl_Layout");
$row = mysql_fetch_row($rs);
$result["total"] = $row[0];
$rs = mysql_query("SELECT * FROM tbl_Layout
LEFT JOIN tbl_Client ON lo_client_id=client_code
LEFT JOIN tbl_Employee on lo_empl_id = emp_code
LEFT JOIN tbl_Activ on lo_act_id = act_id_numb
LEFT JOIN tbl_Month on lo_month = m_numb
limit $offset,$rows");
$items = array();
while($row = mysql_fetch_object($rs)){
array_push($items, $row);
}
$result["rows"] = $items;
echo json_encode($result);
?>
-----------------
save_te.php
----------------
<?php
$lo_client_id = $_REQUEST['lo_client_id'];
$lo_empl_id = $_REQUEST['lo_empl_id'];
$lo_month = $_REQUEST['lo_month'];
$lo_year = $_POST['lo_year'];
$act_id_numb = $_POST['act_id_numb'];
$act_time = $_REQUEST['act_time'];
$lo_desc = $_REQUEST['act_desc'];
//**********************************************************************************
//
// I just start using POST instead of REQUEST ( I read about the risk of $_REQUEST )
// windows.onload:
// To check and see the variables sent by te.php
//
// This page receive
// YES = $lo_client_id, $lo_empl_id, $lo_month , $lo_year
// No = $act_id_numb, $act_time, $lo_desc
//
//**********************************************************************************
echo '<script type="text/javascript"> window.onload=function(){alert("' . $lo_client_id . " - " . $lo_empl_id . " - " . $lo_month . " - " . $lo_year ." - " . $act_id_numb . " - " . $act_time . " - " . $lo_desc . '");} </script>';
include 'conn.php';
$result = @mysql_query($sql);
if ($result){
echo json_encode(array('success'=>true));
} else {
echo json_encode(array('msg'=>'Some errors occured.'));
}
?>