Jump to content

Date field problem


f.ismayil

Recommended Posts

I have such a little code. If I echo $order_date, I receive normal date in YYYY-MM-DD format. But when I use $order_date in mysql query it is not showing me anything. I do not receive any error or warning also.

 

Please help me.

 

$query = "SELECT Product,Amount FROM orders WHERE Date='$order_date'";

$result = mysql_query($query) or die(mysql_error());

 

while($products_list = mysql_fetch_array($result)) {

  echo "<tr>";

    echo "<td>" . $products_list["Product"] . "</td>";

    echo "<td>" . $products_list["Amount"] . "</td>";

  echo "</tr>";

}

Link to comment
Share on other sites

try:

$query = "SELECT Product,Amount FROM orders WHERE Date='".$order_date."'";
$result = mysql_query($query) or die(mysql_error());

while($products_list = mysql_fetch_array($result)) {
  echo "<tr>";
    echo "<td>" . $products_list["Product"] . "</td>";
    echo "<td>" . $products_list["Amount"] . "</td>";
  echo "</tr>";
}

Link to comment
Share on other sites

Jnerocorp, that is no different than what the OP posted; adding string concatenation isn't going to fix the problem.

 

Is there a field in the table named 'Date', and if there is, what is its data type?

 

Echo the query string and make sure it contains the values you think it should contain.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.