我有一个问题,我需要帮助。基本上我试图从数据库查询信息到新闻 - 自动收报机样式类型的数组。我可以显示文本而不是图像,因为它是BLOB格式。我试图在PDO中编写代码,但我仍然是一个新手。我在这里阅读了很多关于获取blob图像并显示它们的文章。但是大多数文章都有关于弃用代码的说明。任何可以提供帮助的人都将不胜感激。这是我的源代码如下。
<style style="text/css">
.scroll-up {
height: 500px;
width: 400px;
overflow: hidden;
position: relative;
background: yellow;
color: black;
border: 1px solid black;
}
.scroll-up p {
position: absolute;
width: 400px;
padding-right: 100%;
height: 100%;
margin: 0;
line-height: 50px;
text-align: center;
/* Starting position */
-moz-transform:translateY(100%);
-webkit-transform:translateY(100%);
transform:translateY(100%);
/* Apply animation to this element */
-moz-animation: scroll-up 20s linear infinite;
-webkit-animation: scroll-up 20s linear infinite;
animation: scroll-up 20s linear infinite;
}
.clones_wrapper {
height: 500px;
width: 400px;
overflow: hidden;
position: relative;
background: yellow;
color: black;
border: 1px solid black;
}
/* Move it (define the animation) */
@-moz-keyframes scroll-up {
0% { -moz-transform: translateY(100%); }
100% { -moz-transform: translateY(-100%); }
}
@-webkit-keyframes scroll-up {
0% { -webkit-transform: translateY(100%); }
100% { -webkit-transform: translateY(-100%); }
}
@keyframes scroll-up {
0% {
-moz-transform: translateY(100%); /* Browser bug fix */
-webkit-transform: translateY(100%); /* Browser bug fix */
transform: translateY(100%);
}
100% {
-moz-transform: translateY(-100%); /* Browser bug fix */
-webkit-transform: translateY(-100%); /* Browser bug fix */
transform: translateY(-100%);
}
}
</style>
<div class="clones_wrapper">
<h2 align='center'>Clones</h2>
<table style = width:400px;><tr><th>Strain</th><th>Type</th><th>Rating</th><th>Price</th></tr></table>
<div class="scroll-up">
<p><?php
echo "<table>";
echo "<marquee behavior='scroll', direction='up'></marquee>";
class TableRows extends RecursiveIteratorIterator {
function __construct($it) {
parent::__construct($it, self::LEAVES_ONLY);
}
function current() {
return "<td align='center' style='width:150px;'>" . parent::current(). "</td>";
}
function beginChildren() {
echo "<tr>";
}
function endChildren() {
echo "</tr>" . "\n";
}
}
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "clonemenudb";
try {
$conn = new PDO("mysql:host=$servername;dbname=clonemenudb", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT strain, type, imagefile, price FROM clones_db");
$stmt->execute();
// set the resulting array to associative
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
echo $v;
}
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
echo "</table>";
?>
</p>
</div>
</div>
答案 0 :(得分:0)
using System;
using System.Collections.Generic;
using System.Linq;
namespace Test
{
class Program
{
static void Main(string[] args)
{
var fullList = new List<object> { 1, "bob2", "bob3", 4 };
var subsetOfFullList = new HashSet<object> { fullList[3], fullList[1] };
IReadOnlyList<object> filteredList = fullList.Where(z => subsetOfFullList.Contains(z)).ToList();
Console.WriteLine(string.Join(",", filteredList));
Console.ReadLine();
}
}
}