patheticsam Posted January 17, 2009 Share Posted January 17, 2009 Hi! I have a little script here and I have a little problem with it... Here the so script so I can explain what's wrong.....I'm doing a time manager script so here I select the data from MySQL database and I print it into a table below... $sql = "SELECT `id`, `date`, `start_time`, `lenght`, `client_first`, `client_last`, `city`, `host`, `status`, `note` FROM booking WHERE host='$host' AND city='$city' ORDER by date AND start_time"; $req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); while($data = mysql_fetch_array($req)) $endtime = $data[start_time] + $data[lenght]; <---This is the problem.... Let's says that $data[start_time] is 9:00:00 in mySQL and the $data[lenght] is 1:15:00.....the result for $endtime should be 10:15:00...But as soon as I put this line in my code all the others $data stop displaying and $endtime only display 10(instead of 10:15:00)....If I take out that line(the red one) The table prints normally with all the mySQL data.... echo " <table border=0 width=100% cellspacing=0 cellpadding=0> <tr> <tr bgcolor=F4F4F4> <td width=20%>$data[client_first] $data[client_last]</td> <td width=20%>$data[start_time] @ $endtime</td> </tr> Can anyone tell me what i'm doing wrong??? Thanks a lot!! Quote Link to comment https://forums.phpfreaks.com/topic/141214-solved-what-am-i-doing-wrong/ Share on other sites More sharing options...
.josh Posted January 17, 2009 Share Posted January 17, 2009 $sql = "SELECT `id`, `date`, `start_time`, `lenght`, `client_first`, `client_last`, `city`, `host`, `status`, `note`, (`start_time` + `lenght`) as endtime FROM booking WHERE host='$host' AND city='$city' ORDER by `date` AND `start_time`"; . . . $endtime = $data['endtime']; Quote Link to comment https://forums.phpfreaks.com/topic/141214-solved-what-am-i-doing-wrong/#findComment-739100 Share on other sites More sharing options...
patheticsam Posted January 17, 2009 Author Share Posted January 17, 2009 Thanks it worked!!!! The only thing is that it gives me the result as 101500 instead of 10:15:00...Is there anything I can do for it? Quote Link to comment https://forums.phpfreaks.com/topic/141214-solved-what-am-i-doing-wrong/#findComment-739102 Share on other sites More sharing options...
.josh Posted January 17, 2009 Share Posted January 17, 2009 oops. $sql = "SELECT `id`, `date`, `start_time`, `lenght`, `client_first`, `client_last`, `city`, `host`, `status`, `note`, ADDTIME(`start_time`,`lenght`) as endtime FROM booking WHERE host='$host' AND city='$city' ORDER by `date` AND `start_time`"; Quote Link to comment https://forums.phpfreaks.com/topic/141214-solved-what-am-i-doing-wrong/#findComment-739107 Share on other sites More sharing options...
patheticsam Posted January 17, 2009 Author Share Posted January 17, 2009 Thanks It worked!! But I had to put the TIME function instead of ADDTIME....but thank you it's really appreciated!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/141214-solved-what-am-i-doing-wrong/#findComment-739109 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.