Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'arrays'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 7 results

  1. Hi everybody, I want to write a php code that extract numbers say 4567 from an image when you press scan button and then sum the numbers together. I have used one javascript library but I'm having problem in converting the numbers into an array. pls. I need an help urgently.
  2. I'm having a problem with a foreach loop that isn't doing what I need it to. I want to take an array of id numbers, fetch the figures related to that id number from my mysql db and sum them. Initially the problem was that my loop was 'overwriting itself' so that the only summing it did was of the last id number. Then after I fixed that, although I have used a 'unique array', it seems that the loop is still summing everything, ie if the array contains the same id number 8 times, it loops through and multiplies that figure x8 (at least I think that's what it's doing). I'm not sure why while($row_outputs=mysqli_fetch_array($run_projects)){ $prog_name = $row_outputs['prog_name']; $proj_name = $row_outputs['name']; $projectId = $row_outputs['id']; $proj_array = array($projectId); $proj_array_uni = array_unique($proj_array); $projecty = ''; foreach($proj_array as $projectile){ $projectile = trim($projectile); $projecty .= $projectile; $get_outputs_active = "SELECT * FROM projects WHERE project_id=$projectile AND impact_area='1'"; $run_outputs_active = mysqli_query($conn, $get_outputs_active); while ($row_outputs_active =mysqli_fetch_array($run_outputs_active)){ $total_outputs_active += $row_outputs_active['total_cost']; } $ftotal_outputs_active = number_format($total_outputs_active,2); $get_outputs_run = "SELECT * FROM projects WHERE project_id=$projectile AND impact_area='2'"; $run_outputs_run = mysqli_query($conn, $get_outputs_run); while ($row_outputs_run =mysqli_fetch_array($run_outputs_run)){ $total_outputs_run += $row_outputs_run['total_cost']; } } ?> Can anybody see what my problem is? Thanks.
  3. Hi Larry, First of all, thanks for the book. It's being surprisingly easy to follow. I'm currently going through chapter 07 (arrays) and I was doing the excercise in "Transforming Between Strings and Array", I first created my list.html file and then on the list.php, this is what I wrote (HTML omitted): <?php //Get text from form $sorted_words = explode(' ',$_POST['words']); //Sort values sort($sorted_words); //Turn array back into a string $string_words = implode("<br />",$sorted_words); //Prints string print "<p>Alphabetized version of your text: <br />$string_words</p>"; ?> Everything working fine. However, the moment I add something else as separator: $sorted_words = explode(',',$_POST['words']); It prints out the phrase exactly as entered in the form, nothing seems to happen, no errors either. Where is the problem? PS: I've seen you are currently working on the 5th edition of "PHP and MySQL for Dynamic Web Sites". Any updates of how is it going? Planning to buy it as song as it gets published Many thanks in advance, Luis.
  4. From the book: Create two different name variables, using the existing first- and last-name variables: $ name1 = '$ first_name $ last_name'; $ name2 = "$ first_name $ last_name"; Technically speaking-- why aren't $name1 and $name2 arrays? I keep telling myself that arrays are variables with two or more values.
  5. I probably have some kind of visual/spacial related learning disability. I know that a form sends data to the server where php processes it and outputs it to the browser. Words alone don't always work for me. I have to draw things as if I were trying to explain it to someone else. Some times that helps me to see that my logic simply doesn't compute. Thought I was good to go with arrays... $var = array('dog', 'cat', '2', 'blue'); $var now contains all the values in the array. But, in the book, the syntax (using post) is: $title = $_POST['title']; $name= $_POST['name']; $email= $_POST['email']; To this newb it appears that the array concept has been abandoned for a multi-variable "device". I realize it's my inability to grasp it. (Tried to post the drawing but got "that extension not allowed" with png, gif, jpg. Finally gave up and put in a link instead) My drawing shows what I think happens. (I like to think I--at least-- have that much right.) But it still seems clunky. Would like to get a grip on this and share with other seniors (dob: 12-7-45). http://chattanoogacentral1964.com/drawing.php
  6. Hi, I am trying to get this code to work, and can't figure out what I'm not doing correctly. New to javascript, PHP and HTML. My PHP code below is not working. I select records from some data base files and store all of the records in an array. I display the information from the first record on the screen. When the "Next" button on the screen is clicked, I want to read the array and get the next record and display that information on the screen. The user will continue to hit the "Next" button until all the records have been displayed on the screen for review. I've tried to do this various ways and just cannot get it to work, and this is my latest version. I didn't know how to get the $item_array code to work within the javascript code.So now I am trying to test the VAR mytest from the javascript. Do I need to use AJAX to pass it or is there a better way? Or how do I get the code to work in javascript? Any help would be appreciated!! Regards, Roy My array definition: $item_array = array(); Sample data from array: [10009] => Array ( [iTEM] => 10009) [10063] => Array ( [iTEM] => 10063) [10066] => Array ( [iTEM] => 10066) Loading the array from the file: $item_array[$item] = $row; When the "Next" button on screen is clicked, I execute a javascript function, passing a value of 1.The javascript code is executed and mytest = 1 My html code: <input type="button" class="button" value="Next Item" onclick="javascript:setval(1)" /> My script: <script> var mytest = ''; function setval(varval) { mytest= varval; } </script> In PHP code, I'm testing if mytest = 1, then <?php $mytest = mytest; if (mytest == '1') { foreach ($item_array as $key => $value) { $itemkey = $key; echo $itemkey; } } ?>
×
×
  • Create New...