Jump to content

Sharon Ann

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Sharon Ann's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I've just found this bit of SQL and am wondering whether this is what I need, select * from fault where Datediff('date_closed','date_opened')>2; Is this the SQL or is there another way?
  2. Hi I have a table called "fault". In this table I have fields called date_opened and date_closed. I would like to select all records from "fault" whereby the time period between date_opened and date_closed is over 2 days. This is the pseudo code that I think I sort of need, but I'm not sure the correct way to write it in a php page. Select * from fault where (date_closed - date_opened) >2; Can anyone help?
  3. Hi This is probably a very simple question but I have tried a few different ways today and the php keeps sending me error messages. I want to change the colour of the staff number to red when displayed on the page, here is the bit of code I have to work with, echo "Staff Number: "; echo ($row['f_staff_id']) . " "; Where do I put the <font color "red"> </font> tags in the second row? Is it like this? echo "<font color "red">($row['f_staff_id'])</font> . " "; Can anyone sort me out with the correct way? Thanks
  4. Yippee!!!! At last, This is the code that worked....... <?php $first_date_opened=$_GET['first_date_opened']; $second_date_opened=$_GET['second_date_opened']; $conn = @mysql_connect("","","")or die("sorry - could not connect to mysql"); $rs = @mysql_select_db("",$conn) or die("problem with database"); $result="SELECT * FROM fault WHERE date_opened >= '{$first_date_opened}' AND date_opened <= '{$second_date_opened}'"; $query=$_GET['Query']; $rs=mysql_query($result,$conn); $num_rows = mysql_num_rows($rs); if ($query=="submit the form") { echo "The number of faults between these two dates was: "; echo ($num_rows) . " "; echo "<br><br>"; } ?> Thanks very much to Sp00fer26 for helping me out, I'd never have known about the {} otherwise. Sharon
  5. Nope, its still not working. All I'm trying to get is the number of rows entered between one date and the other. Doesn't it drive you mad???
  6. Hi I want to query by date, the number of rows from a table (called faults) which represents the number of entries sent by a user between two dates. The user input will be, Inputbox 1 (first_date_opened - which might be 2006-03-01 for example) Inputbox 2(second_date_opened - which might be 2006-03-30 for example) When this query is sent to the database I want to be able display the total number of rows (representing entries) that have been inputted between these dates on the same page. I have been trying to follow several tutorials and have become totally lost. My code so far is as follows, <form name = "datequery" action = "faultCountByDate.php" method = "GET"> <p><u>Produce a count on the number of faults received between two given dates</u><br><br> <p>Please enter the first date to query: <input type="text" name="first_date_opened"> <p>Please enter the second date to query: <input type="text" name="second_date_opened"> <input type = "submit" name = "Query" value = "Click to count" </form> <?php $first_date_opened=$_GET['first_date_opened']; $second_date_opened=$_GET['second_date_opened']; $conn = @mysql_connect("","","")or die("sorry - could not connect to mysql"); $rs = @mysql_select_db("",$conn) or die("problem with database"); $result= mysql_query("SELECT COUNT (*) FROM fault WHERE date_opened > '$first_date_opened' AND date_opened < '$second_date_opened'")//Error message here for line 104 (Parse error: parse error, unexpected T_VARIABLE on line 104) $query=$_GET['Query']; $num_rows = mysql_num_rows($result); if ($query=="Click to count") { echo "The number of faults is: "; echo ($row['$num_rows']) . " "; echo "<br><br>"; } ?> Being I've been following several tutorials, I have ended up with a bit from each, I don't think I need the $row variable. Can anybody sort me out with the correct way? Thanks
×
×
  • 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.