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
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
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
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
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
Share on other sites

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.