pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Mailtos and links from a query result table!
4+ messages / 4 participants
[nested] [flat]

* Mailtos and links from a query result table!
@ 2002-05-09 20:32  angelo.rigo@globo.com
  0 siblings, 2 replies; 4+ messages in thread

From: angelo.rigo@globo.com @ 2002-05-09 20:32 UTC (permalink / raw)
  To: pgsql-php

Hi!
I need to make mailtos and hiperlinks in a query result table
i dont know wich variable to pass to the <a href =""> to make this happen

my code below is not working! any idea?

printf ("<tr bgcolor='$bgcolor'><td>%s</td><td>%s</td><td><a href='mailto:$myrow[19]'>%s</a></td><td><a
href="$myrow[9]">%s</a></td><td>%s</td><td>%s</td></tr>
",$myrow[1], $myrow[2], $myrow[3], $myrow[19], $myrow[9], $myrow[10]);
$row++;
}
while ($row < $numrows);
printf ("</table>
");
pg_close($db);
?>



________________________________________
A busca mais veloz e precisa da internet. Acesse agora: http://www.zoom.com.br.




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Mailtos and links from a query result table!
@ 2002-05-09 20:43  Papp Gyozo <pgerzson@freestart.hu>
  parent: angelo.rigo@globo.com
  1 sibling, 1 reply; 4+ messages in thread

From: Papp Gyozo @ 2002-05-09 20:43 UTC (permalink / raw)
  To: angelo.rigo@globo.com; pgsql-php

2002. május 9. 22:32 dátummal angelo.rigo@globo.com ezt írta:
>Hi!
>I need to make mailtos and hiperlinks in a query result table
>i dont know wich variable to pass to the <a href =""> to make this
> happen

I suggest to you using named fields.You can achieve this by calling
pg_fetch_array with PGSQL_ASSOC parameter (or pg_fetch_object())

	$myrow = pg_fetch_array($result, $row, PGSQL_ASSOC);

Then you can use $myrow['email'], etc, whatever you named those columns 
in postgres.

>
>my code below is not working! any idea?
>
>printf ("<tr bgcolor='$bgcolor'><td>%s</td><td>%s</td><td><a
> href='mailto:$myrow[19]'>%s</a></td><td><a
> href="$myrow[9]">%s</a></td><td>%s</td><td>%s</td></tr>
>",$myrow[1], $myrow[2], $myrow[3], $myrow[19], $myrow[9], $myrow[10]);
>$row++;
>}
>while ($row < $numrows);
>printf ("</table>
>");
>pg_close($db);
>?>
>
>
>
>________________________________________
>A busca mais veloz e precisa da internet. Acesse agora:
> http://www.zoom.com.br.
>
>
>---------------------------(end of
> broadcast)--------------------------- TIP 4: Don't 'kill -9' the
> postmaster

-- 
Papp, Győző
- pgerzson@freestart.hu



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Mailtos and links from a query result table!
@ 2002-05-09 21:31  Surojit Niyogi <surojit@bungeecode.com>
  parent: Papp Gyozo <pgerzson@freestart.hu>
  0 siblings, 0 replies; 4+ messages in thread

From: Surojit Niyogi @ 2002-05-09 21:31 UTC (permalink / raw)
  To: pgerzson@freestart.hu; +Cc: angelo.rigo@globo.com; pgsql-php

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-2">
  <title></title>
</head>
<body>
Doing this would be good also if you expect to alter your table in the future.
 <br>
<br>
-Surojit<br>
<br>
Papp Gyozo wrote:<br>
<blockquote type="cite" cite="midE175ul4-0000Vt-00@pompom.freestart.hu">
  <pre wrap="">2002. május 9. 22:32 dátummal <a class="moz-txt-link-abbreviated" href="mailto:angelo.rigo@globo.com">angelo.rigo@globo.com</a> ezt írta:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Hi!
I need to make mailtos and hiperlinks in a query result table
i dont know wich variable to pass to the &lt;a href =""&gt; to make this
happen
    </pre>
  </blockquote>
  <pre wrap=""><!---->
I suggest to you using named fields.You can achieve this by calling
pg_fetch_array with PGSQL_ASSOC parameter (or pg_fetch_object())

	$myrow = pg_fetch_array($result, $row, PGSQL_ASSOC);

Then you can use $myrow['email'], etc, whatever you named those columns 
in postgres.

  </pre>
  <blockquote type="cite">
    <pre wrap="">my code below is not working! any idea?

printf ("&lt;tr bgcolor='$bgcolor'&gt;&lt;td&gt;%s&lt;/td&gt;&lt;td&gt;%s&lt;/td&gt;&lt;td&gt;&lt;a
href='<a class="moz-txt-link-freetext" href="mailto:$myrow[19">mailto:$myrow[19</a>]'&gt;%s&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a
href="$myrow[9]"&gt;%s&lt;/a&gt;&lt;/td&gt;&lt;td&gt;%s&lt;/td&gt;&lt;td&gt;%s&lt;/td&gt;&lt;/tr&gt;
",$myrow[1], $myrow[2], $myrow[3], $myrow[19], $myrow[9], $myrow[10]);
$row++;
}
while ($row &lt; $numrows);
printf ("&lt;/table&gt;
");
pg_close($db);
?&gt;



________________________________________
A busca mais veloz e precisa da internet. Acesse agora:
<a class="moz-txt-link-freetext" href="http://www.zoom.com.br">http://www.zoom.com.br</a;.


---------------------------(end of
broadcast)--------------------------- TIP 4: Don't 'kill -9' the
postmaster
    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
</blockquote>
<br>
</body>
</html>




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Mailtos and links from a query result table!
@ 2002-05-09 22:13  Keary Suska <hierophant@pcisys.net>
  parent: angelo.rigo@globo.com
  1 sibling, 0 replies; 4+ messages in thread

From: Keary Suska @ 2002-05-09 22:13 UTC (permalink / raw)
  To: pgsql-php

on 5/9/02 2:32 PM, angelo.rigo@globo.com purportedly said:

> Hi!
> I need to make mailtos and hiperlinks in a query result table
> i dont know wich variable to pass to the <a href =""> to make this happen

Neither can we, since you don't give us your table schema, or the database
calls. What is your select statement? What function are you using to
retrieve rows?

> my code below is not working! any idea?

No. We have no idea what "not working" means. If you want help, you will
need to explicitly indicate what is not happening the way that you would
expect. And you should include all code for the algorithm (you can leave out
the pg_connect(), as that shouldn't be necessary, and is a security risk).
The snippet below is useless to determine what may be wrong.

> printf ("<tr bgcolor='$bgcolor'><td>%s</td><td>%s</td><td><a
> href='mailto:$myrow[19]'>%s</a></td><td><a
> href="$myrow[9]">%s</a></td><td>%s</td><td>%s</td></tr>
> ",$myrow[1], $myrow[2], $myrow[3], $myrow[19], $myrow[9], $myrow[10]);
> $row++;
> }
> while ($row < $numrows);
> printf ("</table>
> ");
> pg_close($db);

A tip: on top of using associative arrays as was mentioned in a previous
response, your use of printf() is superfluous and functions only to make
your code more difficult to read. This isn't C--use print():

print <<<EOS
<tr bgcolor='$bgcolor'>
<td>$myrow[1]</td>
<td>$myrow[2]</td>
<td><a href='mailto:$myrow[19]'>$myrow[3]</a></td>
<td><a href="$myrow[9]">$myrow[19]</a></td>
<td>$myrow[9]</td><td>$myrow[10]</td>
</tr>

EOS;

Much cleaner, no?

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2002-05-09 22:13 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-05-09 20:32 Mailtos and links from a query result table! angelo.rigo@globo.com
2002-05-09 20:43 ` Papp Gyozo <pgerzson@freestart.hu>
2002-05-09 21:31   ` Surojit Niyogi <surojit@bungeecode.com>
2002-05-09 22:13 ` Keary Suska <hierophant@pcisys.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox