在我的数据库中,我有3个表:
train_information:
+----------+-----------------+------------------+
| train_id | number_of_axles | number_of_bogies |
+----------+-----------------+------------------+
| 1 | 4 | 2 |
+----------+-----------------+------------------+
Run Code Online (Sandbox Code Playgroud)
轴:
+---------+----------+------+----------+
| axle_id | train_id | axle | distance |
+---------+----------+------+----------+
| 1 | 1 | 1 | 2500 |
| 2 | 1 | 2 | 5000 |
| 3 | 1 | 3 | 2500 |
+---------+----------+------+----------+
Run Code Online (Sandbox Code Playgroud)
转向架:
+----------+----------+---------+----------+
| bogie_id | train_id | axle_nr | bogie_nr |
+----------+----------+---------+----------+
| 1 | 1 | 1 | 1 | …
Run Code Online (Sandbox Code Playgroud) 我现在有一个看起来像这样的页面:
这个代码是:
<?php
$count_axle = $database->count_axles($_GET['train_id']);
foreach($count_axle as $counting){
}?>
<div id="axle_bogie_border">
<img id="count_train_image" src="Images/add_train1.png" alt="Train look" style="width:<?php echo $counting['totaldistance']; ?>%">
<?php
$show_axle = $database->axles($_GET['train_id']);
?>
<div id="axle_position_count">
<?php
foreach($show_axle as $axlefigure){ ?>
<div id="count_axle_figure" style="margin-left:<?php echo $counting['totaldistance']; ?>%">
<?php echo $axlefigure['axle'] ?>
</div>
<?php
}
?><br /><br /><br />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
和css:
#axle_bogie_border {
border: 2px solid black;
width: 100%;
height: auto;
overflow-x: scroll;
white-space: nowrap;
}
#count_train_image{
margin-left: 10%;
margin-right: 10%;
height: 100px;
display: inline-block;
position: relative;
float: …
Run Code Online (Sandbox Code Playgroud) 所以我有2张桌子.
train_information
user_train_information
当有人在表单中提交某些内容时.它放在train_information
表中,看起来像这样:
现在,当人们登录并从选择器中选择火车时.他发生在数据库中:
在另一个页面上,我希望用户能够查看他们在一段时间内选择的所有内容.所以我运行一个查询:SELECT * FROM user_train_information WHERE user_id=user_id;
这显示了我的表user_train_information
但是可以显示train_information user_id = user_id吗?因为我希望用户显示他添加的火车.
编辑:
我现在拥有的:
function testingggg() {
$sql = "SELECT *
FROM train_information
INNER JOIN user_train_information
ON train_information.train_id = user_train_information.train_id
WHERE user_train_information.user_id = user_id";
$sth = $this->pdo->prepare($sql);
$sth->bindParam("user_id", $_GET["user_id"], PDO::PARAM_INT);
$sth->execute();
return $sth->fetchAll();
}
Run Code Online (Sandbox Code Playgroud)
我在这里打电话给我:
<?php
$summary = $database->testingggg();
?>
<?php
foreach ($summary as $result){
echo $result['train_name'];
}
?>
Run Code Online (Sandbox Code Playgroud)
我收到错误:
编辑:它正在使用此代码:
<div id="navigation">
<ul class="menu">
<li><a href="/index.php">Home</a></li>
<li><a href="/about">About Me</a></li>
<li><a href="/blog">Blog</a></li>
<li><a href="/projects">Projects</a></li>
<li><a href="/contact">Contact</a></li>
<li><a href="/time">Current Time</a></li>
<li><a href="/help">Help Me</a></li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
以及使类活跃的代码:
<script>
$(function () {
var url = window.location.pathname,
urlRegExp = new RegExp(url.replace(/\/$/, '') + "$");
$('#navigation a').each(function () {
if (urlRegExp.test(this.href.replace(/\/$/, ''))) {
$(this).addClass('active');
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
这个现在正在运作,但是当我要去Site/Projects/Project1
它时没有任何活动.当我转到Site/Project
s时,它会使项目标签处于活动状态.
所以它正在工作,但我也希望项目标签在我打开时保持活动状态 Site/Projects/Project1
我在 HTML、CSS 中有一个圆圈评分项目(不知道他们的真名),基本上圆圈周围的蓝色条会上升到数字的点。
我希望该栏在页面加载时作为动画播放。目前我使用 PHP 来输出数字,但这意味着栏没有动画。
请看图片
我认为这可以完成的一种简单方法是,如果 PHP 有任何内置函数来输出最多一个数字,例如,它不是输出 3,而是 1,2,3,这可以制作动画。
代码 :
<div id="quad_rating_circle">
<div class="c100 p<?php echo $score; ?> medium custom center dark fill">
<span><?php echo $score; ?></span>
<div class="slice">
<div class="bar"></div>
<div class="fill"></div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我花了一个小时但没有想出任何东西,非常感谢任何帮助。
谢谢
我有一个如下所示的数据库表:
现在.这是DetectorID 1541 的状态历史记录指示器.
我只想在我的网站上显示1行.为此,我执行以下查询.
[Query]
public IQueryable<ScannerStatusHistory> GetScannerStatusHistoryy(int detectorID)
{
return ObjectContext.ScannerStatusHistories.Where(t => t.DetectorID == detectorID).OrderByDescending(d => d.TimeStamp).Take(1); ;
}
Run Code Online (Sandbox Code Playgroud)
它做了什么,它抓住了最新的行(基于TimeStamp)并显示它.
这会给我结果ScannerStatusHistoryID 61
.
但是,我想拥有的是上次更改值的行.
正如你所看到的ScannerStatusHistoryID 54
,RC3
有一个值4
.然后ScannerStatusHistoryID 57
,它又变回了3
.
从那时起,价值观没有改变.
我想拥有的是获取的查询ScannerStatusHistoryID 57
.再次直到值变化,然后我希望它抓住那个中的第一个.
我如何实现这一目标?我正在考虑计算与最后一个查询匹配的结果.但是,在此示例中,它将返回7个结果(因为前4个与最后3个相同).所以它不会给你正确的结果.
我有一个像这样的数字表:
______________________________________
| axle_id | train_id | axle | distance |
|_________|__________|______|__________|
| 1 | 1 | 1 | 20 |
| 2 | 1 | 2 | 50 |
| 3 | 1 | 3 | 200 |
| 4 | 1 | 4 | 50 |
| 5 | 1 | 5 | 200 |
| 6 | 1 | 6 | 50 |
| 7 | 1 | 7 | 200 |
| 8 | 1 | …
Run Code Online (Sandbox Code Playgroud) 例如,我有4个复选框(可以更多可以更少).
我有一个如下所示的数据库表:
+----------+----------+
| id | value |
+----------+----------+
| 1 | NULL |
| 2 | NULL |
| 3 | NULL |
| 4 | NULL |
+----------+----------+
Run Code Online (Sandbox Code Playgroud)
现在当我选择2个盒子时,按下:保存.(保存按钮在数据库中插入值并刷新页面)
数据库插入值1.这是我选择并保存2个选项后屏幕和数据库的样子:
+----------+----------+
| id | value |
+----------+----------+
| 1 | 1 |
| 2 | 1 |
| 3 | NULL |
| 4 | NULL |
+----------+----------+
Run Code Online (Sandbox Code Playgroud)
现在这很好,但我希望下一个值为2.
但我不知道如何!
码:
<?php
$x = 1;
foreach($show_axle as $bogiebox){ ?>
<td>
<?php
if($bogiebox['bogie_nr'] == ''){
?>
<input type='hidden'
name='bogie_id[<?php …
Run Code Online (Sandbox Code Playgroud) 我正在计算我的数据库的结果.如果它低于50,我想将它们除以2.示例:
if(CountResults < 50)
{
//CountResults = 39
int divided = CountResults / 2; //Results in 19
}
Run Code Online (Sandbox Code Playgroud)
我想要的是:
if(CountResults < 50)
{
//CountResults = 39
int divided = CountResults / 2; //Results in 19,5
Math.Round(divided, 0);
}
Run Code Online (Sandbox Code Playgroud)
我希望能够将它向上和向下舍入.
所以我得到结果19.5两次.一旦我希望它是19,一次是20.
我如何实现这一目标?