Re: Table help needed

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

 



On Sat, Oct 20, 2012 at 2:52 PM, admin <admin@xxxxxxxxxxxxxxxxxxx> wrote:
> I want to apologize for the comments that followed my reply, seems some people can't make constructive comments
> if their life depended on it.

So happy you've taken it upon yourself to right all the wrongs in the
world. Perhaps you can start by weeding your own garden.

> While the more complex version in PDO is the preferred method to obtain objects
> from mysql. This does require you to have the basic fundamentals of object oriented programming skills,
> which I am guessing at this point you do not have based on how the question was phrased.

Not really. Writing classes would definitely require OOP skills. Using
classes is quite another thing, and so much easier to get up on. The
documentation is full of examples on how to do this. Reflexively, none
of the lines containing PDO is any more complicated than making
procedure calls.

Compare mysqli procedural and object code, and PDO code:

procedural: $db = mysqli_connect($host,$user,$pass,$dbname);
object: $db = new mysql($host,$user,$pass,$dbname);
PDO: $db = new PDO("mysql:host=$host,dbname=$dbname",$user,$pass);

procedural: $result = mysqli_query($db,$sql);
object: $result = $db->query($sql);
PDO: $result = $db->query($sql);

procedural: $row = mysqli_fetch_row($result);
object: $row = $result->fetch_row();
PDO: $row = $result->fetch();

Or putting the result processing in a loop:

procedural: while ($row = mysqli_fetch_row($result)) { /* process row */ }
object: while ($row = $db->fetch_row($result)) { /* process row */ }
PDO: foreach ($result as $row) { /* process row */ }

Putting it linearly:

Procedural:

$db = mysqli_connect($host,$user,$pass,$dbname);
$result = mysqli_query($db,$sql);
while ($row = mysqli_fetch_row($result)) {
  /* process row */
}

Object:

$db = new mysqli($host,$user,$pass,$dbname);
$result = $db->query($sql);
while ($row = $result->fetch_row()) {
  /* process row */
}

PDO:

$db = new PDO("mysql:host=$host;dbname=$dbname",$user,$pass);
foreach (($db->query($sql)) as $row) {
  /* process row */
}

*Really* not getting how PDO is more complicated.

> There are many people in the list who will gladly point you in the direction to learning aids and tutorials to get you started.

Apparently you aren't one of them.

* Link I posted a few days ago: http://www.phptherightway.com/

* http://devzone.zend.com/6/php-101-php-for-the-absolute-beginner/
** In particular: this page does *exactly* what the OP asked for: 3
column table of data:
http://devzone.zend.com/6/php-101-php-for-the-absolute-beginner/ (done
in the old mysql style)

* if watching videos is more one's style: http://phpacademy.org/tutorials.php

* if y'all like the about.com sites (I don't): http://php.about.com/

*IF*, however, the OP's stuckness is the result of not understanding
HTML <table> markup, then I have a whole different set of links:

* http://html.net/tutorials/html/lesson10.php - on making tables
* http://w3schools.com/html/html_tables.asp - the w3schools.com site
has tutorials on all kinds of webish stuff

Also, in general, http://www.webmonkey.com/ has provided many
beginners with a leg up on many different aspects of web development.

-- 
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