PHP with XML, simple blog

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
midfielder
Forum Newbie
Posts: 1
Joined: Fri Jun 30, 2006 8:11 pm

PHP with XML, simple blog

Post by midfielder »

Ok I am making a simple blog script with XML.
My problem is reading from the XML file.
I only want to display the latest blog post, which should be the last element from my XML file. I also have links included like "Next" / "Previous" where if clicked it'll goto the next and previous posts from the XML file.

Anyway, how can I display only one, the latest post on the web page without loading the entire XML file to memory and sifting through it all to the last element?
And how can i jump to the next element?

If I were using javascript it would be easy by using javascript:productTable.nextPage() and doing something like <table datasrc='#xmldata' datapagesize="1" id="productTable"> <span datafld='element1'>

But I'm trying to do it with PHP.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

How are the XML sheet made? By a database query?
Robert Plank
Forum Contributor
Posts: 110
Joined: Sun Dec 26, 2004 9:04 pm
Contact:

Post by Robert Plank »

Multiple XML files, one for each entry?

Or an XML list of byte offsets for each entry in the file.
texasrenegade
Forum Newbie
Posts: 6
Joined: Thu Jun 29, 2006 1:16 pm

Post by texasrenegade »

To only get one result, you are changing the repeat region by a set number and not all.

To get the latest one, you set the sort order, ascending or descending, descending in this case.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Midfielder, post some XML. I think that would be helpful to everyone that reads this post.

Texasrenegade, got any examples? Again, that would be very helpful for folks that are reading this later and are looking for the same type of help.
texasrenegade
Forum Newbie
Posts: 6
Joined: Thu Jun 29, 2006 1:16 pm

Post by texasrenegade »

I only know how to do this in Dreamweaver. I use xhtml transitional but could be using strict.

Here is a link to a tutorial

http://livedocs.macromedia.com/dreamwea ... _dis14.htm

that saves me from detailing all the steps.

Also on a side note:

Note: Microsoft ASP.NET refers to a recordset as a DataSet. If you are working with ASP.NET document types, the dialog boxes and menu choices specific to ASP.NET use the label DataSet. The Dreamweaver documentation generically refers to both types as recordsets, but uses DataSet when specifically describing ASP.NET features.

Now, there are even behaviors or extensions available for Dreamweaver to help this. I could create an example I guess and he could just modify the code... for his needs.

Let me know...


r
texasrenegade
Forum Newbie
Posts: 6
Joined: Thu Jun 29, 2006 1:16 pm

Post by texasrenegade »

Ok,

go here

http://localhost/Client_durys/HTML_page ... isplay.php

and click on the link Testing Theory

and see how the pages will have PREV and NEXT for the records.


Is this what you mean?



r
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

texasrenegade wrote:Ok,

go here

http://localhost/Client_durys/HTML_page ... isplay.php

and click on the link Testing Theory

and see how the pages will have PREV and NEXT for the records.


Is this what you mean?



r
You linked to your localhost sever. You'll need to post an IP address or transfer the files to a server :)
texasrenegade
Forum Newbie
Posts: 6
Joined: Thu Jun 29, 2006 1:16 pm

Post by texasrenegade »

Post Reply