Re: Question about acessing databases and formatting output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 09, 2005 at 10:41:22PM +0530, bala chandar wrote:
> On 5/9/05, The Doctor <doctor@xxxxxxxxxxxxxxxxx> wrote:
> > On Mon, May 09, 2005 at 08:19:47PM +0530, bala chandar wrote:
> > > Hi,
> > >
> > > On 5/9/05, The Doctor <doctor@xxxxxxxxxxxxxxxxx> wrote:
> > > > On Mon, May 09, 2005 at 08:29:34AM +0530, bala chandar wrote:
> > > > > On 5/9/05, bala chandar <mbchandar@xxxxxxxxx> wrote:
> > > > > > Hi
> > > > > >
> > > > > > On 5/9/05, The Doctor <doctor@xxxxxxxxxxxxxxxxx> wrote:
> > > > > > > On Sun, May 08, 2005 at 01:49:08PM -0600, The Doctor wrote:
> > > > > > > > On Sun, May 08, 2005 at 08:56:25PM +0530, bala chandar wrote:
> > > > > > > > > On 5/8/05, The Doctor <doctor@xxxxxxxxxxxxxxxxx> wrote:
> > > > > > > > > > On Thu, May 05, 2005 at 05:49:38AM -0600, The Doctor wrote:
> > > > > > > > > > > On Thu, May 05, 2005 at 10:11:14AM +0530, bala chandar wrote:
> > > > > > > > > > > > hi,
> > > > > > > > > > > >
> > > > > > > > > > > > On 5/5/05, The Doctor <doctor@xxxxxxxxxxxxxxxxx> wrote:
> > > > > > > > > > > > > This is probably easy, but how does
> > > > > > > > > > > > > one access a database, mysql or oracle or postgresql,
> > > > > > > > > > > > > and
> > > > > > > > > > > > > present the data in a tabular format?
> > > > > > > > > > > > >
> > > > > > > > > > > > > --
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > check out http://in2.php.net/mysql
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Looks good to me.
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > So far so good except my blobs are appearing as is instead of
> > > > > > > > > > as an interpret item.  What next?
> > > > > > > > > > > > --
> > > > > > > > >
> > > > > > > > > what are you storing in BLOB?
> > > > > > > > >
> > > > > > > >
> > > > > > > > First a .tgf and then a jpg.
> > > > > >
> > > > >  hey, check out this. this might help you
> > > > >
> > > > >  http://www.zend.com/zend/trick/tricks-sept-2001.php
> > > > >
> > > > > http://forum.100megswebhosting.com/archive/index.php/t-2971.html
> > > > > >
> > > > > > > >
> > > > > > >
> > > > > > > Is their a way to embed the third column?
> > > > > > >
> > > > > > > And what changes do I need to make to the php code?
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > > Seems to be correct.  Here is what I think:
> > > >
> > > > All the non-blobs are working fine; it is the blobs that are turning up
> > > > as text instead of data.  Can you not tell the PHP scripts the following:
> > > >
> > > > if a blob then present the data as binary
> > > > else
> > > > present the text
> > > > endif
> > > > ?
> > >
> > > I think you cannot judge the content of the blob.  for text use the
> > > data type text instead of blob
> > >
> > 
> > Can you please clarify?
> 
> kindly check this link
> http://forums.devshed.com/archive/t-63144/UserContributed-PHP-Mysql-and-Images
>

I shall read closely.

Today I did generate a script, but I am lacking the
fact that I cannot tell the script not to treat the blob differetly:

 
<? session_start(); ?>
<html>
<head>
<title>db -- query_1</title>
<meta name="generator" content="PHP Generator Wizard">
</head>
<style type="text/css">
  body {
    background-color: #FFFFFF;
    color: #004080;
    font-family: Arial;
    font-size: 12px;
  }
  .bd {
    background-color: #FFFFFF;
    color: #004080;
    font-family: Arial;
    font-size: 12px;
  }
  .tbl {
    background-color: #FFFFFF;
  }
  a:link { 
    color: #FF0000;
    font-family: Arial;
    font-size: 12px;
  }
  a:active { 
    color: #0000FF;
    font-family: Arial;
    font-size: 12px;
  }
  a:visited { 
    color: #800080;
    font-family: Arial;
    font-size: 12px;
  }
  .hr {
    background-color: #336699;
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:link {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:active {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:visited {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  .dr {
    background-color: #FFFFFF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
  }
  .sr {
    background-color: #FFFFCF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
  }
</style>
<table width="100%">
<tr>


<td width="5%">
</td>
<td bgcolor="#e0e0e0">
</td>
<td width="5%">
</td>
<td width="80%" valign="top">
<?
  $conn = connect();
  $showrecs = 100;
  $pagerange = 10;

  $a = @$HTTP_GET_VARS["a"];
  $recid = @$HTTP_GET_VARS["recid"];

  $page = @$HTTP_GET_VARS["page"];
  if (!isset($page)) $page = 1;

  switch ($a) {
    case "view":
      viewrec($recid);
      break;
    default:
      select();
      break;
  }


  mysql_close($conn);
?>
</td></tr></table>
</html>

<? function select()
  {
  global $showrecs;
  global $page;

  $res = sql_select();
  $count = mysql_num_rows($res);
  if ($count % $showrecs != 0) {
    $pagecount = intval($count / $showrecs) + 1;
  }
  else {
    $pagecount = intval($count / $showrecs);
  }
  $startrec = $showrecs * ($page - 1);
  @mysql_data_seek($res, $startrec);
  $reccount = min($showrecs * $page, $count);
  $fields = array ("catno", "name1", "structure");
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr><td>Table: query_1</td></tr>
<tr><td>Records shown: <? echo $startrec + 1 ?> - <? echo $reccount ?> of <? echo $count ?></td></tr>
</table>
<hr size="1" noshade>
<? showpagenav($page, $pagecount); ?>
<br>
<table class="tbl" border="0" cellspacing="1" cellpadding="5"width="100%">
<tr>
<?
  reset($fields);
  foreach($fields as $val){
?>
	
<td class="hr"><? echo $val ?></td>

<? } ?>
</tr>
<?
  for ($i = $startrec; $i < $reccount; $i++)
  {
    $row = mysql_fetch_array($res);
    $style = "dr";
    if ($i % 2 != 0) {
      $style = "sr";
    }
?>
<tr>
<?
  reset($fields);
  foreach($fields as $val) {
    
?>


<td class="<? echo $style ?>"> <? echo $row["$val"] ?>

</td>

<? } ?>


<td class="<? echo $style ?>"><a href="query_1.php?a=view&recid=<? echo $i ?>">View</a></td>
</tr>
<?
  }
  mysql_free_result($res);
?>
</table>
<br>
<? showpagenav($page, $pagecount); ?>
<? } ?>

<? function showrow($row)
  {
?>
<table class="tbl" border="0" cellspacing="1" cellpadding="5"width="50%">
<tr>
<td class="hr">catno&nbsp;</td>
<td class="dr"><? echo $row["catno"] ?></td>
</tr>
<tr>
<td class="hr">name1&nbsp;</td>
<td class="dr"><? echo $row["name1"] ?></td>
</tr>
</table>
<? } ?>

<? function showpagenav($page, $pagecount)
{
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<? if ($page > 1) { ?>
<td><a href="query_1.php?page=<? echo $page - 1 ?>">&lt;&lt;&nbsp;Prev</a>&nbsp;</td>
<? } ?>
<?
  global $pagerange;

  if ($pagecount > 1) {

  if ($pagecount % $pagerange != 0) {
    $rangecount = intval($pagecount / $pagerange) + 1;
  }
  else {
    $rangecount = intval($pagecount / $pagerange);
  }
  for ($i = 1; $i < $rangecount + 1; $i++) {
    $startpage = (($i - 1) * $pagerange) + 1;
    $count = min($i * $pagerange, $pagecount);

    if ((($page >= $startpage) && ($page <= ($i * $pagerange)))) {
      for ($j = $startpage; $j < $count + 1; $j++) {
        if ($j == $page) {
?>
<td><b><? echo $j ?></b></td>
<? } else { ?>
<td><a href="query_1.php?page=<? echo $j ?>"><? echo $j ?></a></td>
<? } } } else { ?>
<td><a href="query_1.php?page=<? echo $startpage ?>"><? echo $startpage ."..." .$count ?></a></td>
<? } } } ?>
<? if ($page < $pagecount) { ?>
<td>&nbsp;<a href="query_1.php?page=<? echo $page + 1 ?>">Next&nbsp;&gt;&gt;</a>&nbsp;</td>
<? } ?>
</tr>
</table>
<? } ?>

<? function showrecnav($a, $recid, $count)
{
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><a href="query_1.php">Index Page</a></td>
<? if ($recid > 0) { ?>
<td><a href="query_1.php?a=<? echo $a ?>&recid=<? echo $recid - 1 ?>">Prior Record</a></td>
<? } if ($recid < $count) { ?>
<td><a href="query_1.php?a=<? echo $a ?>&recid=<? echo $recid + 1 ?>">Next Record</a></td>
<? } ?>
</tr>
</table>
<hr size="1" noshade>
<? } ?>


<? function viewrec($recid)
{
  $res = sql_select();
  $count = mysql_num_rows($res);
  @mysql_data_seek($res, $recid);
  $row = mysql_fetch_array($res);
  showrecnav("view", $recid, $count);
?>
<br>
<? showrow($row) ?>
<?
  mysql_free_result($res);
} ?>

<? function connect()
{
  $conn = mysql_connect("doctor.nl2k.ab.ca", "user", "passwd");
  mysql_select_db("db");
  return $conn;
}

function sql_select()
{
  global $conn;

  $sql = "SELECT * FROM table ";
  $res = mysql_query($sql, $conn) or die(mysql_error());
  return $res;
} ?>
> 
> -- 
> bala> balachandar muruganantham
> blog> lynx http://chandar.blogspot.com
> web> http://www.chennaishopping.com
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

-- 
Member - Liberal International	
This is doctor@xxxxxxxxxx	Ici doctor@xxxxxxxxxx
God Queen and country! Beware Anti-Christ rising!
BC, Vote Liberal!!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux