执行单一分配,需要导入表数据并将数字转换为十六进制数。 我尝试使用unHex()但转换字符串时非常混乱。 有没有更简单的方法来转换它们?
这是表数据的屏幕截图:
Table table;
void setup() {
size(200, 200);
background(255);
table = loadTable("msfw15.csv", "header");
}
void draw() {
//Getting tags, probably an easier way.
String work = table.getString(0, 1);
String fashion = table.getString(1, 1);
String blogger = table.getString(2, 1);
String girlsnight = table.getString(3, 1);
String backstage = table.getString(4, 1);
String ootd = table.getString(5, 1);
String melbourne = table.getString(6, 1);
String sydney = table.getString(7, 1);
String emergingdesigner = table.getString(8, 1);
String fashiongram = table.getString(9, 1);
String foodblogger = table.getString(10, 1);
String hiphop = table.getString(11, 1);
String muji = table.getString(12, 1);
String monochrome = table.getString(13, 1);
String swag = table.getString(14, 1);
String alannahhill = table.getString(15, 1);
String popsofcolour = table.getString(16, 1);
String stylesketch = table.getString(17, 1);
String artist = table.getString(18, 1);
String designer = table.getString(19, 1);
String model = table.getString(20, 1);
String vogue = table.getString(21, 1);
String knitwear = table.getString(22, 1);
String knitting = table.getString(23, 1);
color workd = unhex("FF" + work);
fill(workd);
noStroke();
rect(50, 50, 100, 100);
}
答案 0 :(得分:1)
首先,我认为你真的需要了解<?php
session_start();
if (!$_SESSION['loggedInUser']) {
header("Location: login.php");
}
$resultMessage = null;
include ('db.php');
$query = "SELECT * from user";
$result = mysqli_query($connection, $query);
mysqli_close($connection);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Client Area</title>
</head>
<body>
<?php
// Check for Header Injections
function has_header_injection($str) {
return preg_match( "/[\r\n]/", $str );
}
$missingitemname = '<p><strong> Please Enter Item Name</p></strong>';
if (isset($_POST['submit_form'])) {
$itemname = $_POST["item-name"];
$brandname = $_POST["brand"];
$description = $_POST["description"];
$availability = $_POST["availability"];
$contact = $_POST["contact-p"];
$address = $_POST["address"];
$email = $_POST["email"];
$location = $_POST["location"];
$file = $_FILES["attach"];
if (!$itemname) {
$errors .= $missingitemname;
} else {
$itemname = filter_var($itemname, FILTER_SANITIZE_STRING);
}
if (!$email) {
$errors .= $missingemail;
} else {
$email = filter_var($email, FILTER_SANITIZE_EMAIL);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errors .= $invalidEmail;
}
}
if (!$brandname) {
$errors .= $missingbrandname;
} else {
$brandname = filter_var($brandname, FILTER_SANITIZE_STRING);
}
if ($errors) {
$resultMessage = '<div class="alert alert-danger">'. $errors .'</div>';
}
else {
$to = "adamskhan123@gmail.com";
$subject ="New Contact";
$message ="<p>Item Name: $itemname.</p>
<p>Brand: $brandname.</p>
<p>Description: $description.</p>
<p>Availability: $availability.</p>
<p>Contact Person: $contact</p>
<p>Email: $email</p>
<p>Location: $location</p>
";
$headers ="Content-type: text/html";
if (mail($to, $subject, $message, $headers)) {
$resultMessage = '<div class="alert alert-success">Thank You. Your message has been sent</div>';
} else {
$resultMessage = '<div class="alert alert-danger">Sorry Please Try Again.</div>';
}
}
}
?>
<div class="container">
<h1>PinTribe</h1>
<p>Welcome <?php echo $_SESSION['loggedInUser']; ?></p>
</div>
<div class="top-content">
<div class="inner-bg">
<div class="container">
<div class="row">
<div class="col-sm-8 col-sm-offset-2 text">
</div>
</div>
<div class="row">
<div class="col-sm-6 col-sm-offset-3 form-box">
<div class="form-top">
<div class="form-top-left">
</div>
</div>
<div class="form-bottom">
<?php echo $resultMessage; ?>
<form role="form" action="dashboard.php" method="post" class="login-form" enctype="multipart/form-data">
<div class="form-group">
<label class="sr-only" for="item-name">Item Name</label>
<input type="text" name="item-name" placeholder="Item Name" class="username form-control" id="item-name">
</div>
<div class="form-group">
<textarea type="text" name="description" placeholder="Description" class="description form-control" id="description" rows="5"></textarea>
</div>
<div class="form-group">
<label class="sr-only" for="email">Email</label>
<input type="email" name="email" placeholder="Email.." class="email form-control" id="email">
</div>
</div>
循环。通过该表应该只需要几行代码。 Here是指向for
循环引用的链接。
接下来,我建议您查看the unhex()
reference:
for
除此之外,您需要更准确地了解您对此感到困惑的内容。 String hs = "FF006699";
int hi = unhex(hs);
fill(hi);
rect(30, 20, 55, 55);
函数如何处理你的预期呢?