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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.