FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Best PHP way to connect to a DB across multiple pages ?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Best PHP way to connect to a DB across multiple pages ? [message #169480 is a reply to message #169477] Tue, 14 September 2010 23:56 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
goldtech wrote:
> Hi,
>
> I have a basic PHP and MYSQL connection question/reality check.
>
> Let's say I have two pages which rely on getting content from the same
> DB. The first page shows all the records from the DB in a brief
> tabular format. If the user sees something they are interested in they
> click a link in a displayed brief record and go to the second page
> which displays a detailed view of the item they clicked on with a
> bigger picture and more info.
>
> This is standard, tons of web pages have this format. Both pages pull
> info from the same DB using PHP. Let's say I post the primary key of
> the item from the brief page and send that key to the detail page. The
> detail page uses the key to access the DB again and get more detailed
> content for that record.
>
> On both pages I access the DB with:
> ...
> $dbc=@mysqli_connect (...... );
> $q = "SELECT.... FROM data";
> $r = @mysqli_query($dbc, $q);
> ...
>
> So I'm make a connection twice, once per each page that uses data from
> the DB. Always done it this way. Question: Is this a correct way to
> do this?
>

More or less yes.

I dont think the overhead of setting up the connection is really
significant.


> Thanks,
>
> Lee G.
>
>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Reference # in var_dump output?
Next Topic: OOP, classes and databases
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 17:17:03 GMT 2024

Total time taken to generate the page: 0.05209 seconds