0

hi everyone i have a search page that will search base one date... but if i search with only date (9/27/2011 ) it will only display the data from database
that has the same date and time but not the whole data in that specific date:

example: in my database i have a data:

cow and has a date and time 9/27/2011 12:00:00 AM
carabao and has a date and time 9/27/2011 12:00:00 AM
chicken and has a date and time 9/27/2011 12:01:00 AM
dog and has a date and time 9/27/2011 12:02:00 AM

but when i search: (9/27/2011 )

it will only display data that has the same time

cow that has 9/27/2011 12:00:00 AM
carabao that has 9/27/2011 12:00:00 AM

......how do i make it all display even they have different time..

this is my code btw:

<?php
$conn=odbc_connect('datasourcegaby','','');

$search=mysql_escape_string($_POST['SEARCH']);

if (!$conn)
{exit("Connection Failed: " . $conn);}
$sql="SELECT GEN1MW,GEN1PF FROM generators where TIMESTOMPX= '$search'";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit("Error in SQL");}
echo "<div class=\"totalx\"><table border=\"1\" style=\"table-layout:fixed\" class=\"totalinsidet\"><tr class=\"topbth\">";
echo "<th>TOTAL MW</th>";



echo "<th>TOTAL Mvar</th></tr>";

while (odbc_fetch_row($rs))
{
$totalmw=odbc_result($rs,"GEN1MW");
$totalmvar=odbc_result($rs,"GEN1PF");

echo "<tr><td style=\"white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word\">$totalmw</td>";
echo "<td style=\"white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word\">$totalmvar</td></tr></div>";


}

echo "</table>";




?>

Edited by Dani: Fixed formatting

3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by calebcook
0

First, please use code tags like this:

$sql="SELECT GEN1MW,GEN1PF FROM generators where TIMESTOMPX LIKE '%$search%'";

Also, answer in the code box.

0

First, please use code tags like this:

$sql="SELECT GEN1MW,GEN1PF FROM generators where TIMESTOMPX LIKE '%$search%'";

Also, answer in the code box.

ill try..

0

thankzz for the answer but not working though..

Edited by uselessninja: n/a

0

thankzz for the answer but not working though..

thankzz i solve my prob here is the code:

$sql="SELECT GEN5MW,GEN5PF,GEN5MVAR FROM generators WHERE convert(datetime,convert(char(10),TIMESTOMPX,101))= '$search'";

thank you for the IDEA...

0

Put the time on a seperate column, and then run the following SQL code:

SELECT * FROM table WHERE date='$search'
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.