Jump to content

Recommended Posts

i have this date format 04:00 and I want to echo it to two drop down boxes, 04 for the first box and 00 for the second box by clicking the Edit button. The value 04:00 had been already display in the form page and I want it to be display on drop down boxes.

 

my code is this..

<?php

$_sql="SELECT day, daydesc, room, starttime, wsid, endtime, location, locationname, roomname FROM

weeklyeventscheddesc WHERE weeklyeventscheddesc.weid=".@$_GET["weid"];

}

$data = $vdb->SelectAll($_sql);

foreach ($data as $s_row)

{

$wsid= $s_row['wsid'];

$room=$s_row['room'];

$day= $s_row['day'];

$location= $s_row['location'];

/* starttime==04:00 this would be the value */

 

?>

<tr>

<td><?php

echo $s_row['daydesc'] ." ". $s_row['starttime']. " ". "-". " ". $s_row['endtime']. " ". "  ". "&nbsp ". "&nbsp ". $s_row['locationname']. "&nbsp ". "&nbsp ". $s_row['roomname'];?>

<td align="right"><input type="submit" name="Edit" value="Edit" id="Edit2" onclick="SelectThisSched('EditSchedule','<?php echo $wsid; ?>','<?php echo $room;?>', '<?php echo $day;?>', '<?php echo $location;?>');ShowHideAdd('EditSchedule','block')"

/></td>

</td>

 

</tr>

 

<?php } ?>

and this is the javascript code

function SelectThisSched(div, wsid, room, day, location)

{

var x=0;

var s;

 

if (document.getElementById) {

x = document.getElementById(div);

if (x)

x.style.display = 'block';

x = document.getElementById('wsid');

if (x)

x.value = wsid;

x = document.getElementById('room');

if (x)

x.value = room;

x = document.getElementById('day');

if (x)

x.value = day;

x = document.getElementById('location');

if (x)

x.value = location;

x = document.getElementById('eActve');

if (x)

x.value = actve;

}

}

Please help me

 

Link to comment
https://forums.phpfreaks.com/topic/172644-how-to-split-date-format/
Share on other sites

I would recommend you have starttime as a timestamp and then do

$hours = date("G",$s_row['starttime']);
$minutes = date("i",$s_row['starttime']);

however if you keep it as a string, you can split it like this

list($hours,$minutes) = explode(":",$s_row['starttime']);

 

EDIT: also this question suite the PHP Help section better (I'll move it)

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.