User Profile

Collapse

Profile Sidebar

Collapse
lozwaldo
lozwaldo
Last Activity: Oct 4 '08, 09:15 PM
Joined: Feb 26 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • lozwaldo
    replied to Associative array within fuction
    in PHP
    Cheers

    Everything is working as it should :)

    ty so much. I really appreciate your patience and help.

    Loz...
    See more | Go to post

    Leave a comment:


  • lozwaldo
    replied to Associative array within fuction
    in PHP
    I took your great advice and simplified the code :) Yay it works........

    one small question. This is returned:

    Exchange Rates USD
    GBP - 0.552272
    USD - 1
    NZD - 1.48695

    10 US Dollars buys you:
    NZD - 5.52272
    NZD - 10.00000
    NZD - 14.86950

    I have tried putting in $key to show currency type but it is taking last value and applying it to all.
    ...
    See more | Go to post

    Leave a comment:


  • lozwaldo
    replied to Associative array within fuction
    in PHP
    I have reread the manual.

    Code:
    /*example 1 - Basic loop thru assoc array*/
    foreach($aExchangeRates as $key => $value)
    {
    	echo $key . " - ". $value . "<br>";
    	
    }
    
    /*example 2 - looping values and passing thru function*/
    foreach($aExchangeRates as $value)
    {
    	echo get_currency($money, $value). "<br>";
    }
    ...
    See more | Go to post

    Leave a comment:


  • lozwaldo
    replied to Associative array within fuction
    in PHP
    Thats correct. Have tried
    Code:
    	foreach($aExchangeRates as $key => $value)
    {
    	echo get_currency($money, $iExchangeRate). "<br>";
    }
    but get this error message

    Notice: Undefined variable: iExchangeRate in C:\Program Files\Apache\ht docs\currency2. php on line 37
    $14.86950

    Code:
    Line 37 is
    echo get_currency($money, $iExchangeRate). "<br>";
    ...
    See more | Go to post

    Leave a comment:


  • lozwaldo
    replied to Associative array within fuction
    in PHP
    Tyvm :)

    I decleared the array outside of the function and then decleared a global var inside the function. Not sure if this is the best wat to do it but it works.

    I have the Foreach loop working well but am having trouble calling and executing the function in the Foreach loop.

    Goal:
    Loop through array and apply function to the values and then output the result.
    Code:
    	foreach($aExchangeRates
    ...
    See more | Go to post

    Leave a comment:


  • lozwaldo
    replied to Associative array within fuction
    in PHP
    Sorry I made a mistake with this reply and don't know how to delete it :)
    See more | Go to post
    Last edited by lozwaldo; Sep 20 '08, 11:09 AM. Reason: Mistake in replying

    Leave a comment:


  • lozwaldo
    started a topic Associative array within fuction
    in PHP

    Associative array within fuction

    Hi
    I could really do with some help here :)
    I am tring to display all of the results from the array without having to write everything out by hand like this

    Code:
    	echo get_currency(1, GBP);
    	echo "<br>";
    	echo get_currency(1, USD);
    	echo "<br>";
    	echo get_currency(2, NZD);
    	echo "<br>";
    I have been trying to...
    See more | Go to post

  • It works :)

    Thank you so much for being so patient and encouraging. I have spent the last day or so making sure that I completely understand the logic behind everything. I have learnt so much from you. I truly appreciate your help!

    I will take your advice and not post again until I have gone through the w3schools page again (and again) and have managed to link up all of the concepts.

    I have searched for...
    See more | Go to post

    Leave a comment:


  • I did this and am passing the correct values through from the results page
    Code:
    Array
    (
    [BGD-162510-xxxx_] => 1
    [BGD-162510-xxxx_] => 1
    [BGD-169620-xxxx_] => 0
    )
    However to do my "for each" loop and substr($ChildID , 0, -1); I need to work out the name of the array. When I have looked at examples of this online they also included the name of the array. Oh well my...
    See more | Go to post

    Leave a comment:


  • What we do is that we don't go through govt or NGOs. Usually if you do that the money never gets to the right people. We ask the community what they need and get them to elect their own representatives and have support offices for the community in the country that are constantly involved in the community as appropriate. We also do other things like trying to end bonded labour and child exploitation etc.

    thats my rant :)
    ...
    See more | Go to post

    Leave a comment:


  • Yep - the place I work for raises money to help communities, especially children, in India, Bangladesh and Africa....
    See more | Go to post

    Leave a comment:


  • Thats awesome

    Array
    (
    [BGD-162510-xxxx_] => 1
    [BGD-162510-xxxx_] => 1
    [BGD-169620-xxxx_] => 0
    )

    Exactly what I wanted to pass through. soon as I get this insert to work I promise I will go through all of the w3s pages before I post on this site again (Can you hear the collective rejoicing of all the experts)

    I tried to use "foreach loop",...
    See more | Go to post

    Leave a comment:


  • Harpreet :)

    PS: From the title (PHP Tutorial) you are using, I guess this is an assignment! Is it? If thats the case, then its better for you if you do it yourself rather than asking here in TheScripts.[/QUOTE]


    FYI - I am absolutely not doing this as part of a course for School. Honestly this is for my own personal development tyvm Loz :)
    See more | Go to post

    Leave a comment:


  • am VERY sorry to waste everyones time

    I have gone through the links.

    1) I have place a standard radio button to test the syntax etc. I have been able to pass test values through the page which will insert new value into db (childf.php)

    Question
    What is the syntax for passing the value for the radio buttons populated by the query to the database.

    [code=php]
    echo "<input...
    See more | Go to post

    Leave a comment:


  • Set up third page (of course) and have insert query ready to go.

    Form on childc.php

    Code:
    <FORM ACTION="childf.php" METHOD="POST">
    <input type="submit" name="IsSponsored[]" value="Submit" />
    </FORM>
    goes to childf.php

    Code:
    <?php
    	$db = mysql_connect('localhost', 'xxx', 'xxx');
    ...
    See more | Go to post

    Leave a comment:


  • lol - of course I do. I'm just getting a bit ahead of myself. Didn't think that one through.

    I'll get back to it then.

    tyvm...
    See more | Go to post

    Leave a comment:


  • Just to be clear
    1)childa.php
    User submits query
    2)childc.php
    returns results
    3)User then changes data displayed in radio button e.g. from "Not_Sponso red" to "Sponsored"
    4)User selects submit button
    5)db is updated with new value

    so
    [code=php]
    /*Your comment*/
    /*<form action="abc.php ">*/
    <FORM ACTION="childa. php"...
    See more | Go to post

    Leave a comment:


  • Hi Again :)

    thanks for the tip

    did that but am not sure about syntax when parsing values from db

    [code=php]

    <FORM ACTION="childa. php" METHOD="POST">
    <input type="submit" value="submit" />
    </FORM>

    <?php
    $db = mysql_connect(' localhost', 'xxx', 'xxx');
    mysql_select_db ("child",$db );...
    See more | Go to post

    Leave a comment:


  • woo hoo
    got radio buttons to change value.

    Am trying to set up insert query now. If anyone would like to help out it would be really cool. Currently I am still trying to work out which value to parse :)

    [code=php]
    /*this box checked if IsSponsored = 1*/
    echo "<input type=\"radio\" name=\"".$show['ChildID']." \" value=\"1\" ".$sponsore d[$show['IsSponsored']]."></input>Is...
    See more | Go to post
    Last edited by ronverdonk; Feb 28 '08, 10:44 AM. Reason: code within appropriate code tags

    Leave a comment:


  • mistake here :( ---------------------------------------------------------
    See more | Go to post
    Last edited by lozwaldo; Feb 28 '08, 06:38 AM. Reason: wrong code tags

    Leave a comment:

No activity results to display
Show More
Working...