Jump to content

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

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.