Jump to content

chuy08

Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

chuy08's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. If I have a multidimensional array like the following: Array $records => Array 0 => [Product] 30 year, [Rate]6.0; 1 => [Product] 30 year, [Rate]6.0; 2 => [Product] Pay Option, [Rate]1.0; 3 => [Product] Pay Option, [Rate]1.0; How could I flatten this to achieve an array that only has unique Product values, basically removing $records['1] and $records['3'] in this example?
  2. Given the following XML Doc <Consumer> <Programs> <Program> <Title>30 Year</Title> <author>Juan Rodriguez</author> <publisher>abc</publisher> </Program> <Program> <Title>20 Year</Title> <author>Albert Rodriguez</author> <publisher>abc</publisher> </Program> <Program> <Title>10 Year</Title> <author>Jose Guzman</author> <publisher>xyz</publisher> </Program> How could I construct a table like the following: Title | Author | ABC Publishing | 30 Year | Juan Rodriguez | 20 Year | Albert Rodriguez | XYZ Publishing 10 Year | Jose Guzman | Currently I can build a dynamic table using the following but I can't figure out how to only print out the publisher once as a heading for all the products that match it, and then when a new publisher is detected print a new header and output all matching published products beneath that. $file = 'results.xml'; // Loading the results into a new DomDocument $dom1 = new DOMDocument('1.0', 'ISO-8859-1'); $dom1->load($file, LIBXML_NOBLANKS); <?php echo("<TR>"); echo("<TH></TH>"); echo("<TH>Title</TH>"); echo("<TH>Author</TH>"); echo("<TH>Publisher</TH>"); $root = $dom1->documentElement; $title = $dom1->getElementsByTagName("Title"); $author = $dom1->getElementsByTagName("Author"); $publisher = $dom1->getElementsByTagName("Publisher"); $length = $title->length; for ($x=0; $x < $length; $x++) { echo "<TR><TD>".$title->item($x)->nodeValue."</TD>"; echo "<TD>".$author->item($x)->nodeValue."</TD>"; echo "<TD>".$publisher->item($x)->nodeValue."</TD></TR>"; The above code actually outputs Title | Author | Publisher
  3. I have constructed a framed web form.  The frames are equally divided into two rows taking up 50% of the screen space each.  The top frame is supposed to be static and the bottom frame is where results should be returned when web form is submitted.  Currently when I land on this framed web form within a browser I am getting a blank screen.  What I would like to have is a message below that prompts the user to fill in above to get results.  My problem is the test that I am using to evaluate if the POST array has been initialized or not.  I have constructed an if/else statement that is supposed to test for this, example below: if (is_array($pricing))     {         $pricing = $_POST['pricing'];         print_r($_POST);  //just for testing purposes only     } else {         echo "Please fill out form above to get results below<BR>";       } When I land on the page for the first time the Please fill out form above... condition is met and printed.  Once I begin to fill in my webform and select the submit button I can't seem to get my test to ever evaluate to true.  Adding my $pricing = $_POST and print_r command to the false section of the if/else statement does what it's supposed to do, but why is the test not responding accordingly.  Any help appreciated.    
  4. I have a simple web form that is posting values to an array called info like so: <input type="text" name="info['fname']" size="20"> <input type="text" name="info['lname']" size="20"> on the subsequent page I am calling for the array like so: $info = $_POST['info']; and then I am trying to fill the captured information into a printable form like so: <?php print $info['fname'] ?><?php print $info['lname'] ?> I am getting an Notice: Undefined index: fname in C:\Inetpub\wwwroot\lead_sheet.php on line 35.  What am I doing wrong. When I attempt to print_r($_POST); the post is printed and the keys are all there just a defined on the previous page.  Any help would be appreciated and I could post more code if necessary.
  5. I have a simple web form that is posting values to an array called info like so: <input type="text" name="info['fname']" size="20"> <input type="text" name="info['lname']" size="20"> on the subsequent page I am calling for the array like so: $info = $_POST['info']; and then I am trying to fill the captured information into a printable form like so: <?php print $info['fname'] ?><?php print $info['lname'] ?> I am getting an Notice: Undefined index: fname in C:\Inetpub\wwwroot\lead_sheet.php on line 35.  What am I doing wrong. When I attempt to print_r($_POST); the post is printed and the keys are all there just a defined on the previous page.  Any help would be appreciated and I could post more code if necessary.
  6. given the following array: $sql['city'] = 'Fremont'; $sql['state']= "CA"; $sql['zip'] = "94538" how would you concatenate these array variables to appear as follows: Fremont, CA  94538 I have tried the following: $faddress = ($sql['city'].$sql['state'].$sql['zip']); print $faddress; But this returns FremontCA94538 How do I add spaces to this array concatenation?
  7. I am new to webservices and am at a loss with this one.  I have bought several books to try and help as well as countless Google searches to try and solve me problem to no avail.  Maybe I am over complicating the situation based on all the different things I have attempted to read over the last couple of days.  The situation is pretty simple.  Given an XML file like so: <Borrower>       <FirstName>Bob</FirstName>       <LastName>Smith</LastName>       <Address>1234 White lane</Address> </Borrower> How can I post this to a given URL: http://consumer.example.com/xmlparse.aspx I have read many things on DOM or SAX for parsing of XML documents and many things regarding REST, XML-RPC, or SOAP but I just can't get any easy to follow examples that fit my needs.  Any help greatly appreciated. -chuy
  8. I am trying to create an XML file using a PHP script.  The XML File looks something like this: <?xml version="1.0" encoding="ISO-8859-1"?> <ConsumerDirectXML> <UserParams id="1" BrokerID="1"/>         <LoanParams>         <FirstLeinAmt>500000</FirstLeinAmt>         <ChooseProductTypeID>1</ChooseProductTypeID>         </LoanParams> </ConsumerDirectXML> The part that I don't understand is the following.  I have a series of checkboxes with each box having a different value.  If a user were to select 3 checkboxes I need to iterate through the array and write to the ChooseProductTypeID field in the XML file as such,  <ChooseProductTypeID>1,5,7</ChooseProductTypeID>.  I have been able to print out the array variable $num using the following foreach loop: foreach ($total as $num) { print("$num,"); } How would I get this string into the designated XML tag? Currently I am able to write to this XML file using textboxes and the following code for different XML tags in same file.  How would I modify what I am currently using for textboxes to use for the checkboxes while utilitzing the foreach loop.  Below is the method by which I am writting to my XML file:         if ($node_name == "FirstLeinAmt") {           if ($value == $firstlein) {             // Do nothing           } else {             $fl_textnode = $child_obj->firstChild;             $new_firstlein = $doc->createTextNode($firstlein);             $child_obj->replaceChild($new_firstlein, $fl_textnode);           }         }         foreach ($total as $num) {         if ($node_name == "ChoosedProductTypeID") {           if ($value == $num) {             // Do nothing           } else {             $pt_textnode = $child_obj->firstChild;             $new_num = $doc->createTextNode("$num,");             $child_obj->replaceChild("$new_num", "$pt_textnode");           }} ... Any help appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.