Skip to main content

Posts

Showing posts from April, 2008

IF Else in PHP

If/else statements are very useful because they allow your code to be expressed in certain situations but not in others. You can control when those situations occur by using control statements such as if/else. Before we delve any further, a basic If / Else statement in PHP looks like the following: Simply put, if a condition happens to be true, the code in pink will be executed. If the condition happens to be false, the code in orange, will be executed. The Else statement is optional though. If you do not specify an Else statement, your code will not do anything if the condition happens to be false. For example, here is the code without an Else statement: -------------------------------------------------------------------------------- Let's take an example involving a robot called kirupaTron that is programmed to do among many other things, cross a busy intersection. kirupaTron is at an intersection. He is programmed to wait for the Walk light before crossing the int...

XML Parsing using PHP

Introduction This tutorial is a continuation of the previous XML tutorial I have written. Because I have already written some background information (very little) I will not add that into this tutorial in order to save space and time. The other tutorial can be found at this link. Formatting XML Ok, since I already went over the basics for formatting XML data and the basics of PHP/XML parsing I'm just going to jump right into the XML and PHP without much of an explanation. For this project I decided to create a mock-news headline parser. Basically, we have our XML file that has news headlines and a brief description of the story. Many of the news-tickers that you see on websites use a process similar to this (often called RSS). Now, on to our XML file. Creating our XML Just as with the last tutorial this XML file is quite simple. We have our highest level "news" tags which encase everything. The next level down is our "story" tags which split up each ...

Generating XML from the Database VB

1. Create a XML class to get data from the database Class clsXML ============================================= Public Function getTOPN() As ADODB.Recordset Dim strSql As String On Error GoTo GErr strSql = "select xmlserialize(content xmlelement(name " & """" & "Party" & """" & " ," & _ "xmlelement(name " & """" & "Party" & """" & ",integer(party))," & _ "xmlelement(name " & """" & "Party" & """" & ",party)," & _ "xmlelement(name " & """" & "W_cand" & """" & ",integer(w_cand))," & _ "xmlelement(name " & """" & "l_cand" & """" & ",integer(l_can...