Jump to content

[SOLVED] What am I doing wrong???


patheticsam

Recommended Posts

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!!

Link to comment
https://forums.phpfreaks.com/topic/141214-solved-what-am-i-doing-wrong/
Share on other sites

$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'];

 

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`";

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.