Jump to content

odbc_fetch_row


Phpnewbie23

Recommended Posts

I am having a issue with a php function. What i am trying to do is populate a table using a ODBC_fetch_row.

 

Here is the code:

 

echo "<table width=60% height=3% cellspacing='1' cellpadding='2' border='1'>";
echo "<tr>";
echo "<th align=center><small>Client</small</th>";
echo "<th align=center><small>Backup Name</small></th>";
echo "<th align=center><small>Start Time</small></th>";
echo "<th align=center><small>End Time</small></th>";
echo "<th align=center><small>Backup Status</small></th>";
echo "</tr>";
//echo "</table>";

   while (odbc_fetch_row($rs))
{
  $client=odbc_result($rs,"CLIENT_NAME");
   $backupname=odbc_result($rs,"BACKUP_NAME");
     $start_time=odbc_result($rs,"BACKUP_START_TIME");
      $end_time=odbc_result($rs,"BACKUP_END_TIME");
	   $remarks=odbc_result($rs,"REMARKS");
	    
  


//echo "<table width=60% height=5% cellspacing='1' cellpadding='2' border='1'>";
echo "<tr>";
echo "<td align=center><small>$client</small></td>","\n";
echo "<td align=center><small>$backupname</small></td>","\n";
echo "<td align=center><small>$start_time</small></td>","\n";
echo "<td align=center><small>$end_time</small></td>","\n";
echo "<td align=center><small>$remarks</small></td>","\n";

echo "</tr>";
echo "</table>";

 

and the result i am getting is see attached image. What i would like to do is have the results in table.

 

Like the first row in the image with $remarks to green if success and red if say SG0000 out of space.

 

I also would like to sort out the time change it from UNIX to windows time and some other stuff but that can been later.

 

 

Cheers

 

 

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/140519-odbc_fetch_row/
Share on other sites

try this:

 

echo "<table width=60% height=3% cellspacing='1' cellpadding='2' border='1'>";
echo "<tr>";
echo "<th align=center><small>Client</small</th>";
echo "<th align=center><small>Backup Name</small></th>";
echo "<th align=center><small>Start Time</small></th>";
echo "<th align=center><small>End Time</small></th>";
echo "<th align=center><small>Backup Status</small></th>";
echo "</tr>";
//echo "</table>";

   while (odbc_fetch_row($rs))
{
  $client=odbc_result($rs,"CLIENT_NAME");
   $backupname=odbc_result($rs,"BACKUP_NAME");
     $start_time=odbc_result($rs,"BACKUP_START_TIME");
      $end_time=odbc_result($rs,"BACKUP_END_TIME");
	   $remarks=odbc_result($rs,"REMARKS");
	    
  


//echo "<table width=60% height=5% cellspacing='1' cellpadding='2' border='1'>";
echo "<tr>";
echo "<td align=center><small>$client</small></td>","\n";
echo "<td align=center><small>$backupname</small></td>","\n";
echo "<td align=center><small>$start_time</small></td>","\n";
echo "<td align=center><small>$end_time</small></td>","\n";
echo "<td align=center><small>$remarks</small></td>","\n";
echo "</tr>";
}

echo "</table>";

 

edit: You forgot the } at the end of the while needs to be before ending the table.

Link to comment
https://forums.phpfreaks.com/topic/140519-odbc_fetch_row/#findComment-735337
Share on other sites

I am trying to work out how to get my time changed from UNIX to user readable time.

 

$start_time=odbc_result($rs,"BACKUP_START_TIME");
$end_time=odbc_result($rs,"BACKUP_END_TIME");

 

The above gets the start and the end time from the database.

The below code puts the data in a table along with other data.

 

echo "<td align=center><small>$start_time</small></td>","\n";
echo "<td align=center><small>$end_time</small></td>","\n";

 

I was just after a little help on how to change the BACKUP_START_TIME also the BACKUP_END_TIME to a readable date format i have been looking at it for most of the day now  ??? ??? ??? ???

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/140519-odbc_fetch_row/#findComment-736154
Share on other sites

Sorry. I dont understand your example or are we on the 2 seperate paths.

 

I already have the time stamps which are populated by the database

the start time BACKUP_START_TIME and the end time BACKUP_END_TIME

 

"see image attached"

 

And instead of:

 

Start time    End Time

1227142806  1227147684

 

I planned to have:

 

Start Time                                                    End Time

Thursday, November 20th 2008, 1:00:06 (GMT)  Thursday, November 20th 2008, 2:21:24 (GMT)

 

or maybe trimmed down abit.

 

Cheers

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/140519-odbc_fetch_row/#findComment-736183
Share on other sites

I do not use odbc so I am confused as to how that works but to convert a timestamp to a date you need to use the php date() function. For example if the $start_time and $end_time in this code:

 

echo "<td align=center><small>$start_time</small></td>","\n";
echo "<td align=center><small>$end_time</small></td>","\n";

 

give you the timestamp then you would change the code to this:

 

echo "<td align=center><small>" . date("m/d/Y", $start_time) . "</small></td>","\n";
echo "<td align=center><small>" . date("m/d/Y", $end_time) . "</small></td>","\n";

 

Which would then make it a date like 01/13/09(January 13 2009). You can check out this site for other examples http://www.tizag.com/phpT/phpdate.php of how to format the date

Link to comment
https://forums.phpfreaks.com/topic/140519-odbc_fetch_row/#findComment-736196
Share on other sites

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.