无法将转换后的数据插入到表中。下面是我如何收集数据的代码。
import UIKit
class BookDetailsView: UIView {
@IBOutlet var wholeView: UIView!
@IBOutlet var borderView: UIView!
@IBOutlet weak var imgBook: UIImageView!
@IBOutlet weak var txtTitle: UITextField!
@IBOutlet weak var txtAuthor: UITextField!
@IBOutlet weak var txtDesc: UITextField!
@IBOutlet weak var btnUploadPhoto: UIButton!
//init for custom draw
override init(frame: CGRect) {
super.init(frame: frame)
customInit()
}
//init for ib
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
customInit()
// fatalError("init(coder:) has not been implemented")
}
private func customInit(){
//load xib
Bundle.main.loadNibNamed("BookDetailsView", owner: self, options: nil)
//add wholeView as subView
addSubview(wholeView)
//auto fit
wholeView.frame = self.bounds
wholeView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
borderView.layer.borderWidth = 3
borderView.layer.cornerRadius = 40
}
}
现在我使用while循环并将出生日期转换为年龄。
<?php
session_start();
$mysqli = new MySQLi('localhost', 'db', 'password', 'username');
$stmt = $mysqli->prepare("SELECT bday FROM uploaded");
$stmt->bind_result($bday);
$stmt->execute();
$stmt->store_result();
部分结果print_r。请注意,每个行或出生日期的数组都没有编号。应该是[0] [1] [2]等...... ??
while ($stmt->fetch()){
$birthDate = $bday;
$birthDate = explode("/", $birthDate);
$age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2])))>
date("md") ? ((date("Y") - $birthDate[2]) - 1 ): (date("Y") - $birthDate[2]));
Save results to my Array
$result_bday = array($age);
} // end loop
完美地完成了这一点。似乎无法插入工作。代码
echo '<pre>';
print_r($result_bday);
echo '</pre>';
Array([0] => 32)
Array([0] => 46)
Array([0] => 19)