Jump to content

Search the Community

Showing results for tags 'logic'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 4 results

  1. Hey. Please help to solve the task Head John very busy lately. And it does not have time to plan the time of your employees manually. So he asked Jerry programmer to write a program that will calculate how much of a certain type of problems his department will be able to solve in the past month. John knows that to solve this type of problem he needs n employees, each of which will deal with a specific case and can not replace the other. Each of these employees will be engaged in the same task ai hours. Total monthly employee fulfills bi hours. Besides John have Jerry, which can be given to the problem of maximum k hours. Jerry can do the work of any other employee, one hour is equal to one hour of Jerry any other employee. John need to understand how the tasks can be performed per month maximum knowing n, k, a1-n, and b1-n Input data The first line is followed by two positive integers n and k (1 ≤ n ≤ 50000, 1 ≤ k ≤ 109) - the number of employees and number of hours of programmer Jerry. In the second line followed by a sequence a1, a2, ..., an (1 ≤ ai ≤ 109), where the i-th number equals the number of hours the i-th employee, required for solving a problem. The third line should be a sequence of b1, b2, ..., bn (1 ≤ bi ≤ 109), where the i-th number equals the number of hours the i-th employee, who is at John. Output Print a single number - the maximum number of tasks that can make the employees of the department with the help of their available hours and programmer Jerry. Examples: Input data 3 1 2 1 4 11 3 16 The result of 4
  2. I am a WP and PHP novice still flailing in the deep end of the pool. I am trying to add some logic to display content on certain pages (via WP templates), not on others. I've made some progress but having issues. Here is the plan: On certain pages with an post type of "EVENT" I want content to appear, but not on OTHER pages with an post type of "EVENT". The problem I am running into is that part of the content is appearing on ALL event pages even if they don't meet the criteria. The logic is intended to be this: If the page is post_type "EVENT", AND if the indicated table contains a field with a record CAT which matches the current "POST ID", AND contains a record TYPE which matches value "1", display table cells which contain text "Presented by: ", an href and an image, else display table cells which contain a nonbreaking space. The problem is that the text "Presented by: " is appearing on ALL the even pages, regardless of whether they meet the criteria or not -- which would tend to indicate a problem with the logic code -- but by the same token the href and image are correctly appearing ONLY on the pages that meet the criteria and are NOT appearing on along with the rogue text on pages which do not meet the criteria. I am sure it is a coding error on my part but I am not sure what. ANY help anyone could give would be GREATLY appreciated. The code involved is below (oh, and I should mention that the code in question is in the HEADER.PHP file): <?php if($post->post_type=='event') { $q1=mysql_query("SELECT * FROM table_name WHERE type = 1 AND cat = $post->ID "); $row_diamond=mysql_fetch_object($q1); if ($q1){ ?> <td width="115" align="right" valign="middle" id="diamond1"><strong style="position:relative;bottom:-25px;">Presented by: </strong></td> <td id="diamond2" width="190"> <a href="<?=$row_diamond->website?>" title="<?=$row_diamond->website_title?>" target="_blank" style="cursor:pointer;"><img style="position:relative;bottom:5px;" src="<?php bloginfo('siteurl'); ?>/wp-content/plugins/sean_event/files/<?=$row_diamond->image?>" alt="<?=$row_diamond->alt_text?>"border="0"></a> <br /> </td> <?php } else{ ?> <td width="115" align="right" valign="middle" id="diamond1"> </td> <td id="diamond2" width="190"> </td> <?php } } ?>
  3. (This question might need to go to a different forum, because it is more of a general programming logic question than a specific PHP question, but I don't know where else to ask. I am writing the program in PHP, so this is the first place I thought of to ask. If I need to move this question somewhere else, please advise. Thanks.) The short version (straight to the point): I need to generate a list of non-sequential integers and then randomize that list. The longer version: I am writing a Bible quiz program and the first page has an HTML form where the user selects a question category (i.e. a book from the Bible.) Once that selection is made, Each question in the MySQL database has an auto-increment questionID (integer) and a categoryname (string) as well as a question and an answer and some other fields. I will need to gather a list of QuestionIDs corresponding to the chosen category, then ask the questions from that category, one-at-a-time--preferably in a random order. The QuestionID is auto-incremented and new questions from 66 categories (66 books in the Bible) will be added daily. I know how to use the rand() function on sequential integers, but this list will not be sequential. Perhaps when I run the for each loop, I can add some code to stuff an array with the QuestionID for each of these questions. I could then randomize that array, put that array into a session variable, and then ask questions from that array of QuestionIDs. Does that sound like a good solution? That solution seems easier to ask than to code, but before attempting to tackle that idea, I thought it would be better to run it by some "PHP Freaks" first. Better ideas out there? Thanks.
  4. Hi everyone, this is my first post here. I need some help with a PHP/MySQL multiple choice quiz that I'm making for a website. I have succesfully created a CMS to create new quizzes and then add questions and answers for it to a MySQL database table. I have written the code to loop through and display the questions and possible answers with radio buttons. I'm having trouble with the logic of correcting the quiz however. I've been searching online and trying different things for 2 days, but nothing I've come up across has helped me. I don't want to just download someone else's multiple choice quiz package, I want to be able to figure this out on my own (well, with your help!) because once I get the logic down, that's only half of what I need to do. No one else's pre-written package suits my needs. Well here goes. I have a CMS that creates a quiz and then adds questions and answers. The database table has the following fields: [id] [quizName] [question] [answerA] [answerB] [answerC] [answerD] [correctAnswer] On my quiz page, I have a dropdown box to select which quiz you want to take. Then I query the database looking for questions which have that quiz name. Here's my code: <form method="post" action="quizzes.php"> <?php $questionNumber = 1; $query = mysql_query("SELECT * FROM quizzes WHERE quizName = '$quizName'"); while ($result = mysql_fetch_array($query)) { ?> <p> <?php echo $questionNumber . ") " . $result['question'] . "<br>"; ?> <input type="radio" name="answer<?php echo $result['id'] ?>" value="A"> <?php echo $result['answerA']; ?> <br> <input type="radio" name="answer<?php echo $result['id'] ?>" value="B"> <?php echo $result['answerB']; ?> <br> <input type="radio" name="answer<?php echo $result['id'] ?>" value="C"> <?php echo $result['answerC']; ?> <br> <input type="radio" name="answer<?php echo $result['id'] ?>" value="D"> <?php echo $result['answerD']; ?> <br> </p> <?php $questionNumber +=1; } ?> <input type="submit" name="checkQuiz" value="Check Quiz"> </form> This displays the questions and answers nicely. I know I need some kind of unique identifier for each question as I'm displaying them all from a single while loop. Then when the submit button is clicked, I need to get the answer selected for each of the questions, and compare it to the correctAnswer field in the database for that question. Nothing I've tried has worked. Can anyone help me out. Even if you give me some pseudo code, I'll code it up myself and see if it works. If it doesn't, I'll paste it here to show you what I've done. Any help would be greatly appreciated! I spent about 20 hours on this to no avail and nothing I've found searching Google has helped me either.
×
×
  • 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.