Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14486
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Pulling ad-hoc data from a database into a PHP web page |
| Date | 2014-11-06 04:54 +0100 |
| Organization | PointedEars Software (PES) |
| Message-ID | <9211084.ztrPHf13qF@PointedEars.de> (permalink) |
| References | <m3ef2b$u9h$1@dont-email.me> |
James Harris wrote:
> I am looking for a good way to pull ad-hoc info from a database into a
> web page. By "good" I mean a way that is efficient for the server and
> convenient for the person writing the web page.
You can't have your cake and eat it.
> Some of the ad-hoc info will be scalars. Some will be lists and, possibly,
> some will be tabular.
With regard to data, a list is a table with one column.
> Is there already a standard way to do things like this?
Yes.
> It's been a whiile since I used PHP but from a quick look it seems it may
> be best to define a number of functions to retrieve and echo data.
Three at most.
> A call to the scalar function would be something like
>
> scalar_get("key")
>
> where the key uniquely identifies a cell in a table.
You mean a _column_. A common ontology for databases is that a database
consists of tables, a table consists of rows and columns, each row and
column consists of fields; the fields of each column that belong to the same
row constitute a record, and several records constitute a data set.
> The subroutine would just echo the result into the output html that gets
> sent to the web browser
As a rule of thumb, you want to escape all output. You may even have to
recode it for proper display.
> Is that reasonable
No.
> and is there a way to make the subroutine efficient given that there may
> be many scalar_get() calls in the body of the page?
Mu. [1]
Next time, ask questions the smart way:
<http://www.catb.org/~esr/faqs/smart-questions.html>
[1] You can cache query results so that you do not have to issue a new query
when you need data from the same data set. But the notion of “ad-hoc
data” contradicts with that approach; “ad-hoc data” changes.
--
PointedEars
Zend Certified PHP Engineer
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Pulling ad-hoc data from a database into a PHP web page "James Harris" <james.harris.1@gmail.com> - 2014-11-06 00:23 +0000
Re: Pulling ad-hoc data from a database into a PHP web page Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-06 04:54 +0100
Re: Pulling ad-hoc data from a database into a PHP web page Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-06 09:19 -0500
Re: Pulling ad-hoc data from a database into a PHP web page "James Harris" <james.harris.1@gmail.com> - 2014-11-06 15:39 +0000
Re: Pulling ad-hoc data from a database into a PHP web page Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-06 11:32 -0500
Re: Pulling ad-hoc data from a database into a PHP web page "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2014-11-26 10:26 +0100
Re: Pulling ad-hoc data from a database into a PHP web page Tim Streater <timstreater@greenbee.net> - 2014-11-26 09:38 +0000
Re: Pulling ad-hoc data from a database into a PHP web page "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2014-11-26 11:56 +0100
Re: Pulling ad-hoc data from a database into a PHP web page Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-26 07:51 -0500
Re: Pulling ad-hoc data from a database into a PHP web page "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2014-11-26 14:24 +0100
Re: Pulling ad-hoc data from a database into a PHP web page Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-26 08:36 -0500
Re: Pulling ad-hoc data from a database into a PHP web page Matthew Carter <m@ahungry.com> - 2014-11-26 10:21 -0500
Re: Pulling ad-hoc data from a database into a PHP web page "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2014-11-26 20:57 +0100
Re: Pulling ad-hoc data from a database into a PHP web page Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-26 16:21 -0500
Re: Pulling ad-hoc data from a database into a PHP web page "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-06 18:27 +0100
Re: Pulling ad-hoc data from a database into a PHP web page "James Harris" <james.harris.1@gmail.com> - 2014-11-06 15:58 +0000
Re: Pulling ad-hoc data from a database into a PHP web page Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-06 21:34 +0100
Re: Pulling ad-hoc data from a database into a PHP web page Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-05 23:00 -0500
Re: Pulling ad-hoc data from a database into a PHP web page "James Harris" <james.harris.1@gmail.com> - 2014-11-06 15:29 +0000
Re: Pulling ad-hoc data from a database into a PHP web page Matthew Carter <m@ahungry.com> - 2014-11-06 10:44 -0500
Re: Pulling ad-hoc data from a database into a PHP web page "James Harris" <james.harris.1@gmail.com> - 2014-11-06 16:15 +0000
Re: Pulling ad-hoc data from a database into a PHP web page Matthew Carter <m@ahungry.com> - 2014-11-06 11:25 -0500
Re: Pulling ad-hoc data from a database into a PHP web page Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-06 12:42 -0500
Re: Pulling ad-hoc data from a database into a PHP web page Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-08 13:50 +0100
Re: Pulling ad-hoc data from a database into a PHP web page Matthew Carter <m@ahungry.com> - 2014-11-08 21:19 -0500
Re: Pulling ad-hoc data from a database into a PHP web page Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-08 22:08 -0500
Re: Pulling ad-hoc data from a database into a PHP web page Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-09 08:09 +0100
Re: Pulling ad-hoc data from a database into a PHP web page "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-06 18:24 +0100
Re: Pulling ad-hoc data from a database into a PHP web page Matthew Carter <m@ahungry.com> - 2014-11-06 12:37 -0500
Re: Pulling ad-hoc data from a database into a PHP web page "James Harris" <james.harris.1@gmail.com> - 2014-11-06 17:51 +0000
Re: Pulling ad-hoc data from a database into a PHP web page "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-06 20:56 +0100
Re: Pulling ad-hoc data from a database into a PHP web page Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-06 12:40 -0500
Re: Pulling ad-hoc data from a database into a PHP web page richard <noreply@example.com> - 2014-11-10 11:17 -0500
Re: Pulling ad-hoc data from a database into a PHP web page Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-10 21:27 +0000
csiph-web