php-windows Digest 21 Jan 2005 00:41:59 -0000 Issue 2544
Topics (messages 25408 through 25415):
Page not displaying all my data
25408 by: Louis Young
25409 by: Warren Vail
Design Assistance
25410 by: Jim MacDiarmid
25411 by: Jason Barnett
25412 by: trystano.aol.com
25413 by: Jim MacDiarmid
25414 by: Jason Barnett
Re: Move to first record mssql
25415 by: Robert Twitty
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Hi there
I'm looping through a table and displaying data for each record, but the
page just stops in the middle of nowhere.
Is there a configuration setting somewhere that could be causing this?
The code looks like this:
while($row=mssql_fetch_array($rsElecTrans))
{
?>
<tr>
<td align="left"
valign="top" class="bluetext"><? echo $row["sType"]; ?></td>
<td align="left"
valign="top"><img src="images/shim.gif" alt="" width="5" height="1"
border="0"></td>
</tr>
<?
}
?>
Problem is it doesn't show all the records it like stops halfway in the one.
TIA
Louis
--- End Message ---
--- Begin Message ---
Louis,
A long shot but does one of the rows contain a "<" less than character in
one of the data elements?
Warren Vail
> -----Original Message-----
> From: Louis Young [mailto:[EMAIL PROTECTED]
> Sent: Thursday, January 20, 2005 12:11 AM
> To: [EMAIL PROTECTED]; [email protected]
> Subject: [PHP-WIN] Page not displaying all my data
>
>
> Hi there
>
> I'm looping through a table and displaying data for each record, but the
> page just stops in the middle of nowhere.
>
> Is there a configuration setting somewhere that could be causing this?
>
> The code looks like this:
>
> while($row=mssql_fetch_array($rsElecTrans))
> {
>
> ?>
> <tr>
> <td align="left"
> valign="top" class="bluetext"><? echo $row["sType"]; ?></td>
> <td align="left"
> valign="top"><img src="images/shim.gif" alt="" width="5" height="1"
> border="0"></td>
>
> </tr>
> <?
>
> }
> ?>
>
>
> Problem is it doesn't show all the records it like stops halfway
> in the one.
>
> TIA
> Louis
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--- End Message ---
--- Begin Message ---
I'm hoping someone can help me with some design thinking.. I'm still
fairly new to php and most of my scripts are written in a rather procedural
format. I'd like to try start thinking in a more object-oriented way. The
piece I'm working on is rather simple but I'm not sure how to arrange
things. Basically, I'm making a list of users for a message board and when
the list is displayed, it looks similar to the following:
Add User <http://>
| ID | Name | Homepage | Action |
----------------------------------------------------------------------------
---------
1 User1 http://... Edit <http://>
| Delete <http://>
2 User2 http://... Edit <http://>
| Delete <http://>
3 User3 http://... Edit <http://>
| Delete <http://>
.
I'd like to be able to do things like:
$obj = new member;
$obj->firstname = "Tim";
$obj->homepage = "www.myhomepage.com";
$obj->saveuser();
Or
$obj->deleteuser($id);
Or
$obj->getuser($id);
I'm not sure if I should include database functionality to this object or if
I should separate it to a database class.
Are there any good examples of doing things like this? I've got the O'reilly
book called PHP Cookbook and I was playing with the example on page 159,
example 7.8..because they start out with what looks like the PEAR DB and
that's what I'm using.
Any thoughts and/or help with this would be greatly appreciated
TIA!
Jim
--- End Message ---
--- Begin Message ---
Jim MacDiarmid wrote:
I'm hoping someone can help me with some design thinking.. I'm still
fairly new to php and most of my scripts are written in a rather procedural
format. I'd like to try start thinking in a more object-oriented way. The
There's no reason why you *have* to use objects. Heck OOP isn't
necessary in the least, especially in a web environment where it is
likely you are going to be changing things around a lot. ;)
That being said: if you *do* decide that organizing your code into
objects is what you want to do is try to use objects to model things in
the simplest way possible. KISS = Keep It Simple Stupid. No offense
intended to you, it's what I say to myself also :)
For example if you want one of the object's methods to produce error
messages well that's great... but don't echo it to the screen. You
might later instead decide that you want to log the errors into a file
(when you move a script into production).
piece I'm working on is rather simple but I'm not sure how to arrange
things. Basically, I'm making a list of users for a message board and when
the list is displayed, it looks similar to the following:
Add User <http://>
| ID | Name | Homepage | Action |
----------------------------------------------------------------------------
---------
1 User1 http://... Edit <http://>
| Delete <http://>
2 User2 http://... Edit <http://>
| Delete <http://>
3 User3 http://... Edit <http://>
| Delete <http://>
..
I'd like to be able to do things like:
$obj = new member;
$obj->firstname = "Tim";
$obj->homepage = "www.myhomepage.com";
$obj->saveuser();
Or
$obj->deleteuser($id);
Or
$obj->getuser($id);
I'm not sure if I should include database functionality to this object or if
I should separate it to a database class.
As stated above: keep objects as simple as possible to give you some
flexibility to use them in the future. The PEAR::DB classes are built
so that you can move from one database to another with relative ease.
So by using a seperate DB object you are able to plug in a new database
instead of oracle / mysql / whatever (should the need ever arise).
Harry Fueck's website http://phppatterns.com/ is a good place to start
learning about objects in PHP.
Are there any good examples of doing things like this? I've got the O'reilly
book called PHP Cookbook and I was playing with the example on page 159,
example 7.8..because they start out with what looks like the PEAR DB and
that's what I'm using.
Any thoughts and/or help with this would be greatly appreciated
TIA!
Jim
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins
--- End Message ---
--- Begin Message ---
Check this threrad out on Sitepoint forums. It doesn't exactly specify an exact
way of doing things, but more so is a strong debate amoungst professional what
they seem the best approach is...because after all, there is no 'CORRECT' way
of it :)
http://www.sitepoint.com/forums/showthread.php?t=208947&highlight=Data+Access+Layer
Thanks
Tryst
--- End Message ---
--- Begin Message ---
Thanks for your thoughts Jason.
In reference to the KISS method you mentioned.. ( taking a quick deep
breath... I resemble that remark!! ;) )
No, actually, the way I normally structure my code is on each page I do the
following:
<?php
/* All includes and requires go here */
/* local functions go here */
/* Start by calling Main() */
main();
function main(){
... php code here...
}
?>
<!--- HTML code here -->
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
</BODY>
</HTML>
It's just when I look at my code it seems too simple as though I'm doing
something wrong. Like when I call a function to add/update/delete data
to/from a table, I'm not sure if I should display any errors that arise or
log them. My understanding with errorhandling is limited. I was thinking
that if I take all related functions that go together with a user, and put
them into a User object would be better.
Hopefully all this makes sense to everyone.
Thanks again for your input.
Jim
-----Original Message-----
From: Jason Barnett [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 20, 2005 9:20 AM
To: [email protected]
Subject: [PHP-WIN] Re: Design Assistance
Jim MacDiarmid wrote:
> I'm hoping someone can help me with some design thinking.. I'm still
> fairly new to php and most of my scripts are written in a rather
procedural
> format. I'd like to try start thinking in a more object-oriented way.
The
There's no reason why you *have* to use objects. Heck OOP isn't
necessary in the least, especially in a web environment where it is
likely you are going to be changing things around a lot. ;)
That being said: if you *do* decide that organizing your code into
objects is what you want to do is try to use objects to model things in
the simplest way possible. KISS = Keep It Simple Stupid. No offense
intended to you, it's what I say to myself also :)
For example if you want one of the object's methods to produce error
messages well that's great... but don't echo it to the screen. You
might later instead decide that you want to log the errors into a file
(when you move a script into production).
> piece I'm working on is rather simple but I'm not sure how to arrange
> things. Basically, I'm making a list of users for a message board and
when
> the list is displayed, it looks similar to the following:
>
>
>
> Add User <http://>
>
>
>
> | ID | Name | Homepage | Action |
>
>
----------------------------------------------------------------------------
> ---------
>
> 1 User1 http://... Edit <http://>
> | Delete <http://>
>
> 2 User2 http://... Edit <http://>
> | Delete <http://>
>
> 3 User3 http://... Edit <http://>
> | Delete <http://>
>
>
>
> ..
>
> I'd like to be able to do things like:
>
>
>
> $obj = new member;
>
> $obj->firstname = "Tim";
>
> $obj->homepage = "www.myhomepage.com";
>
> $obj->saveuser();
>
>
>
> Or
>
>
>
> $obj->deleteuser($id);
>
>
>
> Or
>
>
>
> $obj->getuser($id);
>
>
>
> I'm not sure if I should include database functionality to this object or
if
> I should separate it to a database class.
As stated above: keep objects as simple as possible to give you some
flexibility to use them in the future. The PEAR::DB classes are built
so that you can move from one database to another with relative ease.
So by using a seperate DB object you are able to plug in a new database
instead of oracle / mysql / whatever (should the need ever arise).
Harry Fueck's website http://phppatterns.com/ is a good place to start
learning about objects in PHP.
>
> Are there any good examples of doing things like this? I've got the
O'reilly
> book called PHP Cookbook and I was playing with the example on page 159,
> example 7.8..because they start out with what looks like the PEAR DB and
> that's what I'm using.
>
> Any thoughts and/or help with this would be greatly appreciated
>
>
>
> TIA!
>
>
>
> Jim
>
>
>
>
>
>
>
>
>
>
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plug
ins
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Jim MacDiarmid wrote:
Thanks for your thoughts Jason.
In reference to the KISS method you mentioned.. ( taking a quick deep
breath... I resemble that remark!! ;) )
No, actually, the way I normally structure my code is on each page I do the
following:
<?php
/* All includes and requires go here */
/* local functions go here */
/* Start by calling Main() */
main();
function main(){
A C coder? ;)
... php code here...
}
?>
<!--- HTML code here -->
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
</BODY>
</HTML>
It's just when I look at my code it seems too simple as though I'm doing
something wrong. Like when I call a function to add/update/delete data
to/from a table, I'm not sure if I should display any errors that arise or
First, check out this link:
http://www.php.net/manual/en/function.set-error-handler.php
So in general a good way to handle things is to trigger an error (with
trigger_error imagine that :) and pass the error message that way. Then
your error handler can do with it whatever it needs to do (email you,
log it, echo, etc.). This makes it easier to switch over from
development to production (and back again when something breaks :(
IMO anything that is a message should just be plain text returned /
stored in some variable. This makes it easy to handle and pass on to
other functions. You can also go all-out and use error classes /
exceptions, but they aren't *really* necessary. But useful.
log them. My understanding with errorhandling is limited. I was thinking
that if I take all related functions that go together with a user, and put
them into a User object would be better.
Hopefully all this makes sense to everyone.
Thanks again for your input.
Jim
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins
--- End Message ---
--- Begin Message ---
mssql_data_seek() works for me. Maybe you should post the code prior to
what you have provided.
-- bob
On Thu, 20 Jan 2005, Louis Young wrote:
> Hi there
>
> I'm looping through an mssql dataset, using
> while($row=mssql_fetch_array($rsElecTrans)), but now I would like to
> loop through the same dataset again later on, but inn order to do this I
> need to move to the first record, so I tried:
>
> mssql_data_seek($rsElecTrans, 0);
> while($row=mssql_fetch_array($rsElecTrans)) // this is line 514
>
> But I get the following error:
>
> *Warning*: mssql_fetch_array(): supplied argument is not a valid MS
> SQL-result resource in *C:\Program Files\Apache
> Group\Apache2\htdocs\spar\admin\rpt_electrans.php* on line *514
>
> How does that work?
>
> Cheers
> Louis
> *
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---