PHP来自多个表,但在同一个数据库中(PHP results from multiple tables but in the same database)
我有我的PHP SELECT查询工作,但我需要它显示超过1表的数据。
$sql = "SELECT * from paymentPersonal where `custID`='$custID'"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<br> custID: ". $row["custID"]. " - FirstName: ". $row["firstname"]. " LastName" . $row["lastname"] . " - Mobile: ". $row["mobile"]. " - homephone: ". $row["homephone"]. " - Email: ". $row["email"]."<br>";
这是显示1表的数据的代码,但我需要几个,我试过将它更改为此,看看它会显示更多的表:
$sql = "SELECT * from `paymentPersonal`, `paymentsPayment` where `custID`='$custID'"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<br> custID: ". $row["custID"]. " - FirstName: ". $row["firstname"]. " LastName" . $row["lastname"] . " - Mobile: ". $row["mobile"]. " - homephone: ". $row["homephone"]. " - Email: ". $row["email"]."<br>"; echo "<br> custID: ". $row["custID"]. " - CcName: ". $row["nameoncard"]. " CcNumber" . $row["ccnumber"] . " - ccYear: ". $row["year"]. " - ccMonth: ". $row["month"]. " - ccCode: ". $row["code"]."<br>";
但没有任何运气只是得到一个错误说;
Notice: Trying to get property of non-object in /Applications/XAMPP/xamppfiles/htdocs/horizonphotography/findingcode.php on line 19 0 results
(仅供参考,所有表格中的
custID
)如果您对如何在其他表格上显示数据有所了解,请提供帮助! 谢谢!ive got my php SELECT query working but i need it to display more then 1 table worth of data.
$sql = "SELECT * from paymentPersonal where `custID`='$custID'"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<br> custID: ". $row["custID"]. " - FirstName: ". $row["firstname"]. " LastName" . $row["lastname"] . " - Mobile: ". $row["mobile"]. " - homephone: ". $row["homephone"]. " - Email: ". $row["email"]."<br>";
this is the code that displays the data for the 1 table but i need serveral and ive tried changing it to this to see wether it would display more tables:
$sql = "SELECT * from `paymentPersonal`, `paymentsPayment` where `custID`='$custID'"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<br> custID: ". $row["custID"]. " - FirstName: ". $row["firstname"]. " LastName" . $row["lastname"] . " - Mobile: ". $row["mobile"]. " - homephone: ". $row["homephone"]. " - Email: ". $row["email"]."<br>"; echo "<br> custID: ". $row["custID"]. " - CcName: ". $row["nameoncard"]. " CcNumber" . $row["ccnumber"] . " - ccYear: ". $row["year"]. " - ccMonth: ". $row["month"]. " - ccCode: ". $row["code"]."<br>";
but without any luck just getting an error saying;
Notice: Trying to get property of non-object in /Applications/XAMPP/xamppfiles/htdocs/horizonphotography/findingcode.php on line 19 0 results
(FYI the
custID
is in all of the tables) if you have an idea on how to display the data on this other table please help! thank you!
原文:https://stackoverflow.com/questions/37022063
最满意答案
我不熟悉croniter,但freezegun可以帮助解决这个问题 - 它使用
freezegun.api.FakeDatetime
实例修补对datetime.datetime
所有引用,因此在some_code()
,任何datetime.datetimes
都应该使用freezegun.api.FakeDatetime
实例freezegun.api.FakeDatetime
。 从经验来看,如果你使用freezegun试图模拟时间的流逝,你也可以避免许多令人头疼的间歇性测试失败。from datetime import datetime, timedelta from freeze_gun import freeze_time from other_module import some_code fake_today = datetime.datetime(2017, 7, 11) with_freeze_time(fake_today): some_code() # simulate passage of time to tomorrow with_freeze_time(fake_today + timedelta(days=1)) some_code()
I'm not familiar with croniter, but freezegun may help with this— it patches all references to
datetime.datetime
with instances offreezegun.api.FakeDatetime
, so withinsome_code()
, anydatetime.datetimes
should use instances offreezegun.api.FakeDatetime
. Speaking from experience, you'll also save yourself lots of headaches with intermittent test failures when trying to simulate the passage of time if you use freezegun.from datetime import datetime, timedelta from freeze_gun import freeze_time from other_module import some_code fake_today = datetime.datetime(2017, 7, 11) with_freeze_time(fake_today): some_code() # simulate passage of time to tomorrow with_freeze_time(fake_today + timedelta(days=1)) some_code()
相关问答
更多-
答案是相对简单的。 秒表使用性能计数器对处理器计时器进行计数,处理器之间的机制不同。 DateTime查询系统时钟 - 系统时钟由主板上(可能是石英)水晶时钟的输出通过窗口定期更新。 所有时钟漂移,这两种不同的时序机制将以不同的速率漂移。 在引擎盖下, Stopwatch 使用这个API Stopwatch类帮助操纵托管代码中与时间相关的性能计数器。 具体而言,可以使用Frequency字段和GetTimestamp方法来代替非托管Win32 API QueryPerformanceFrequency和Qu ...
-
重写DateTime.Now(Overriding DateTime.Now)[2023-10-09]
对于单元测试,我建议你看一看Microsoft Moles ,一个隔离框架,它可以让你用你自己的代理来替换对DateTime.Now的调用,它可以返回你想要的任何日期。 For unit testing I would recommend you to take a look at Microsoft Moles, an isolation framework that would let you replace a call to DateTime.Now with your own delegate w ... -
这可能是系统上time.sleep的限制,而不是datetime.now() ......或两者兼而有之。 您运行的是什么操作系统以及Python的哪个版本和发行版? 您的系统可能不提供time.sleep文档中提到的“亚秒级精度”: sleep(...) sleep(seconds) Delay execution for a given number of seconds. The argument may be a floating point number for sub ...
-
我不熟悉croniter,但freezegun可以帮助解决这个问题 - 它使用freezegun.api.FakeDatetime实例修补对datetime.datetime所有引用,因此在some_code() ,任何datetime.datetimes都应该使用freezegun.api.FakeDatetime实例freezegun.api.FakeDatetime 。 从经验来看,如果你使用freezegun试图模拟时间的流逝,你也可以避免许多令人头疼的间歇性测试失败。 from datetime ...
-
DateTime.Now不是属性,它是静态只读属性。 在封面下,readonly属性只是一个返回值的函数调用,因此它可以进行任何想要的处理。 希望这可以帮助。 DateTime.Now isn't an attribute, it's a static readonly property. Under the covers a readonly property is just a function call that returns a value, so it can do any amount of ...
-
如果DateTime.Kind既不是Utc也不是Local,则省略UTC偏移量(例如,“ - 05:00 ”或“Z”)。 您可以按如下方式创建此类DateTime值: DateTime.UtcNow.ToString("o"); // "2012-02-08T19:19:38.5767158Z" new DateTime(DateTime.UtcNow.Ticks).ToString("o"); // "2012-02-08T19:19:38.5767158" new DateTime(DateTime ...
-
最简单的方法是查询一系列日期: game.select().where(game.created_at.between( datetime.date.today(), datetime.date.today() + datetime.timedelta(days=1)) The easiest way is query a range of dates: game.select().where(game.created_at.between( datetime.date.today ...
-
如果您查看此MSDN文章,您会发现它( 强调我的 ): 在内部, DateTime值表示为自0001年1月1日午夜12:00:00起经过的刻度数(100纳秒间隔的数量) 。 实际的DateTime值与在用户界面元素中显示或写入文件时该值的显示方式无关。 DateTime值的出现是格式化操作的结果。 格式化是将值转换为字符串表示的过程。 由于日期和时间值的出现取决于诸如文化,国际标准,应用程序要求和个人偏好等因素,因此DateTime结构通过其ToString方法的重载在格式化日期和时间值方面提供了极大的灵活 ...
-
时间戳是一个有用的元数据。 它不是 - 正如您所发现的 - 可靠的订购标准。 想象一下,你在你的机器上想出了一些解决方案,但现在必须使用两台机器? 你可以让他们的时钟在一纳秒内保持同步吗? 减? 在事件源中,典型的保证仅是事件在单个流中排序,例如一个聚合。 无论如何,这是您的交易保证。 为什么不使用整数来跟踪流中的每个事件的序列? 您的聚合可以生成它,因为它一直在跟踪所有事件。 如果您希望跨流进行排序,则必须集中生成该序列号(使用表示的耦合),或者接受多个流的多次读取并不总是以相同的顺序返回事件,只是一个流 ...
-
此DateTime代码是否与DateTime.now有任何不同(Does this DateTime code do anything different to DateTime.now)[2023-06-30]
它与DateTime.Now相同。 从DateTime获取刻度并将其放在构造函数中将为您提供相同的日期时间: msdn => DateTime(int64 ticks) 但是,您可以从DateTime.Now中丢失时区感知: The Kind property is initialized to Unspecified. For applications in which portability of date and time data or a limited degree of time zone ...