Jump to content

RI1

New Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by RI1

  1. RI1

    census bureau

    Thank you. This code does submit and save, but the values won't show up in the table. Would I need to use java script so it can show up??
  2. RI1

    census bureau

    we still aren't connecting to the data base, but this is what I have so far and I think my biggest issue is making the submit button save the answers when they enter input save it then display what ever they choose(Total, Average, below poverty): <html> <head> <title> Project1.html </title> <link rel="stylesheet" href="Project 1 WEB_RI.CSS"> </head> <body> <h3>Data Collected: </h3> <form action="Project 1 WEB_RI.PHP " method="POST"> <table border="1"> <tr><td> <div> <a href="Project 1 WEB_RI.html">Home</a>&nbsp;&nbsp; <a href="http://itd1.cincinnatistate.edu/PHP-IbrahimR/Content/Week6/RI_Project1Total.html">Total Households Surveyed</a>&nbsp;&nbsp; <a href=" http://itd1.cincinnatistate.edu/PHP-IbrahimR/Content/Week6/RI_Project1Average.html">Average Household Income</a>&nbsp;&nbsp; <a href="http://itd1.cincinnatistate.edu/PHP-IbrahimR/Content/Week6/RI_Project1Poverty.html">Percentage Below Poverty</a> </div> </td></tr> <tr><td> <label>Date of Survey:</label> <input type="date" name="surveyDate" value="2019-01-01" required /> <br /> </td></tr> <tr><td> <label>County and State: </label> <select name="countyState" required> <option>Hamilton, Oh</option> <option>Butler, Oh</option> <option>Boone, Ky</option> <option>Kenton, Ky</option> </select> <br /> </td></tr> <tr><td> <label>Number in Household: </label> <input type="number" name="noOfHouseHold" min="1" required /> <br /> </td></tr> <tr><td> <label>The household yearly income: </label> <input type="number" name="yearlyIncome" min="1" required /> <br /> </td></tr> <tr><td> <input type="submit" value="Submit" /> <input type="reset" value="Reset" /> </td></tr> </form> </table> </body> </html> <?php session_start(); if(!isset($_SESSION['county']) || !isset($_SESSION['state']) || !isset($_SESSION['noOfHousehold']) || !isset($_SESSION['yearlyIncome'])){ return; } //census_process.php <?php session_start(); if(!isset($_SESSION['noOfSurveys'])){ $_SESSION['noOfSurveys']=0; } $index = $_SESSION['noOfSurveys']; $surveyDate = $_POST['surveyDate']; $countyState = explode(",", $_POST['countyState']); $noOfHousehold = $_POST['noOfHouseHold']; $yearlyIncome = $_POST['yearlyIncome']; if(!isset($_SESSION['county'])){ $_SESSION['county'] = array(); } $_SESSION['county'][$index] = $countyState[1]; if(!isset($_SESSION['state'])){ $_SESSION['state'] = array(); } $_SESSION['state'][$index] = $countyState[0]; if(!isset($_SESSION['noOfHousehold'])){ $_SESSION['noOfHousehold'] = array(); } $_SESSION['noOfHousehold'][$index] = $noOfHousehold; if(!isset($_SESSION['yearlyIncome'])){ $_SESSION['yearlyIncome'] = array(); } $_SESSION['yearlyIncome'][$index] = $yearlyIncome; $_SESSION['noOfSurveys']++; header("Location: Project 1 WEB_RI.html"); <?php include_once('.php'); $incomeByState = array(); $incomeByCountry = array(); for($i=0;$i<$_SESSION['noOfSurveys'];$i++){ if(!array_key_exists($_SESSION['country'][$i], $incomeByCountry)){ $incomeByCountry[$_SESSION['country'][$i]] = array(); } if(!array_key_exists($_SESSION['state'][$i], $incomeByState)){ $incomeByState[$_SESSION['state'][$i]] = array(); } array_push($incomeByCountry[$_SESSION['country'][$i]], $_SESSION['yearlyIncome'][$i]); array_push($incomeByState[$_SESSION['state'][$i]], $_SESSION['yearlyIncome'][$i]); } echo "Average household income by Country: <br/>"; foreach($incomeByCountry as $key => $value){ $avg = array_sum($value) / count($value); echo $key.": $".$avg."<br/>"; } echo "<br/> Average household income by State: <br/>"; foreach($incomeByState as $key => $value){ $avg = array_sum($value) / count($value); echo $key.": $".$avg."<br/>"; } <?php include_once("head.php"); $noOfSurveysByState = array_count_values($_SESSION['state']); $noOfSurveysByCountry = array_count_values($_SESSION['country']); echo "No of survery by State: <br/>"; foreach ($noOfSurveysByState as $key => $value) { echo $key.": ".$value."<br/>"; } echo "<br/><br/>No of survery by Country: <br/>"; foreach ($noOfSurveysByCountry as $key => $value) { echo $key.": ".$value."<br/>"; }
  3. RI1

    census bureau

    The results would be presented to the user in different pages for each Total, Average, and Below Poverty: Average Household Income Ohio: $30,000 Hamilton: $40,000 Butler: $20,000 Kentucky: $35,000 Boone: $40,000 Kenton: $35,000
  4. RI1

    census bureau

    There are 4 HTML for this.I think I would need a PHP for each one of them? The main one is : <!DOCTYPE html> <html> <head> <meta > <title> Project1.html </title> <link rel="stylesheet" href="Project 1 WEB_RI.CSS"> <script src="http://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6/html5shiv.min.js"></script> </head> <body> <h3>Data Collected: </h3> <form method="post"action="Project 1 WEB_RI.PHP "> <table border="1"> <tr > <td rowspan="5" colspan = "2"><h3 style="color:black" ; align="center"> <button style="width:50%" type="submit" name= "Submit" Value= "Save Change">Submit</button> <br><br> <button style="width:50%" type="reset" name= "Reset" Value= "Reset">Reset</button><br><br> <a href="http://itd1.cincinnatistate.edu/PHP-IbrahimR/Content/Week6/RI_Project1Poverty.html">Percentage Below Poverty</a><br><br> <a href=" http://itd1.cincinnatistate.edu/PHP-IbrahimR/Content/Week6/RI_Project1Average.html">Average Household Income</a><br><br> <a href="http://itd1.cincinnatistate.edu/PHP-IbrahimR/Content/Week6/RI_Project1Total.html">Total Households Surveyed</a> </td> <td> <label class="three" for="fSurvey"><span>Date of Survey:*</span></label><br> <input colspan= "4" type="date" width="150" id="fSurvey" name="Survey" placeholder="Date of Survey.."></tr> </td> <tr><td> <label class="three" for="fCS"><span>County and State:*</span></label><br> <select County State ="selCS" name="CS" width="150"> <option selected= "Selected" value=""> Select County, State</option> <option value= "Hamilton, OH">Hamilton, OH</option> <option value= "Bulter, OH">Bulter, OH</option> <option value= "Boone, KY">Boone, KY</option> <option value= "Kenton, KY">Kenton, KY</option> </select> </td></tr> <tr><td> <label class="three" for="fHousehold"><span>Number in Household:*</span></label><br> <input colspan= "4" type="number" min="1" width="150" id="fHousehold" name="Household" placeholder="Number of Household.."></tr> </td> </td></tr> <tr><td> <label class="three" for="fyearlyIncome"><span>Household yearly Income:*</span></label><br> <input colspan= "4" type="number" min="1" width="150" id="fyearlyIncome" name="yearlyIncome" placeholder="Household yearly Income.."></tr> </td> </td></tr> <tr> <td class="three" border="thin single black collapse" width="150" colspan= "2" align="right" > <span>*Required Field</span><br> </td></tr> </table> </form>
  5. RI1

    census bureau

    This is the same problem just done in vb.net and I'm trying to do it in PHP: Option Strict On Public Class Form1 Dim strState() As String = {"Hamilton, Oh", "Butler, Oh", "Clermont, Oh", " Warren, Oh", "Campbell, Ky", "Boone, Ky", "Kenton, Ky"} ' selecting from combo box from these Dim dblIncomes() As Double = {0, 0, 0, 0, 0, 0, 0} Dim intCount() As Integer = {0, 0, 0, 0, 0, 0, 0} Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click Dim strCounty As String Dim dblIncome As Double Dim valid As Boolean = True txtIncome.BackColor = Color.White Try strCounty = cboBox.SelectedItem.ToString 'Validation If Validation(txtIncome.Text, dblIncome) = True Then 'loop through the array to get input from each state For i = 0 To strState.Length - 1 If strState(i) = strCounty Then dblIncomes(i) = dblIncomes(i) + dblIncome intCount(i) = intCount(i) + 1 End If Next cboBox.SelectedItem = "" ' Clear txtbox for income txtIncome.Clear() End If Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Public Function Validation(ByVal Income As String, ByRef IncomeNumber As Double) As Boolean If IsNumeric(Income) Then IncomeNumber = CDbl(Income) Else MessageBox.Show("Please enter numbers only and greater than 0 ") ' they aren't entering number or they have 0 for income txtIncome.BackColor = Color.Yellow txtIncome.Focus() Return False End If If cboBox.SelectedIndex = -1 Then MessageBox.Show("Please select a State.") ' they aren't selecting state Return False End If Return True End Function Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click 'Close program Close() End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'load the combo box items collection using the state in array For i = 0 To strState.Length - 1 cboBox.Items.Add(strState(i)) Next End Sub Private Sub btnAverage_Click(sender As Object, e As EventArgs) Handles btnAverage.Click Dim dblOhioAverage As Double Dim dblKentuckyAverage As Double Dim intOhioTotal As Integer Dim intKentuckyTotal As Integer ' Loop the total households surveyed For i = 0 To strState.Length - 1 Select Case strState(i) Case "Hamilton, Oh" dblOhioAverage += dblIncomes(i) intOhioTotal += intCount(i) Case "Butler, Oh" dblOhioAverage += dblIncomes(i) intOhioTotal += intCount(i) Case "Clermont, Oh" dblOhioAverage += dblIncomes(i) intOhioTotal += intCount(i) Case "Warren, Oh" dblOhioAverage += dblIncomes(i) intOhioTotal += intCount(i) Case "Campbell, Ky" dblKentuckyAverage += dblIncomes(i) intKentuckyTotal += intCount(i) Case "Boone, Ky" dblKentuckyAverage += dblIncomes(i) intKentuckyTotal += intCount(i) Case "Kenton, Ky" dblKentuckyAverage += dblIncomes(i) intKentuckyTotal += intCount(i) End Select Next 'Display Total MessageBox.Show("Ohio:" & vbTab & vbTab & FormatCurrency(dblOhioAverage / intOhioTotal) & vbNewLine & " Hamilton:" & vbTab & FormatCurrency(dblIncomes(0)) & vbNewLine & " Butler:" & vbTab & vbTab & FormatCurrency(dblIncomes(1)) & vbNewLine & " Clermont:" & vbTab & FormatCurrency(dblIncomes(2)) & vbNewLine & " Warren:" & vbTab & vbTab & FormatCurrency(dblIncomes(3)) & vbNewLine & "Kentucky:" & vbTab & FormatCurrency(dblKentuckyAverage / intKentuckyTotal) & vbNewLine & " Boone:" & vbTab & vbTab & FormatCurrency(dblIncomes(5)) & vbNewLine & " Campbell:" & vbTab & FormatCurrency(dblIncomes(4)) & vbNewLine & " Kenton:" & vbTab & vbTab & FormatCurrency(dblIncomes(6))) End Sub Private Sub btnTotal_Click(sender As Object, e As EventArgs) Handles btnTotal.Click Dim intOhioTotal As Integer Dim intKentuckyTotal As Integer ' Loop the total households surveyed For i = 0 To strState.Length - 1 Select Case strState(i) Case "Hamilton, Oh" intOhioTotal += intCount(i) Case "Butler, Oh" intOhioTotal += intCount(i) Case "Clermont, Oh" intOhioTotal += intCount(i) Case "Warren, Oh" intOhioTotal += intCount(i) Case "Campbell, Ky" intKentuckyTotal += intCount(i) Case "Boone, Ky" intKentuckyTotal += intCount(i) Case "Kenton, Ky" intKentuckyTotal += intCount(i) End Select Next 'Display Total MessageBox.Show("Ohio:" & vbTab & vbTab & intOhioTotal & vbNewLine & " Hamilton:" & vbTab & intCount(0) & vbNewLine & " Butler:" & vbTab & vbTab & intCount(1) & vbNewLine & " Clermont:" & vbTab & intCount(2) & vbNewLine & " Warren:" & vbTab & vbTab & intCount(3) & vbNewLine & "Kentucky:" & vbTab & intKentuckyTotal & vbNewLine & " Boone:" & vbTab & vbTab & intCount(5) & vbNewLine & " Campbell:" & vbTab & intCount(4) & vbNewLine & " Kenton:" & vbTab & vbTab & intCount(6)) End Sub End Class
  6. RI1

    census bureau

    I'm still a beginner. That is my code. Only comments I need is the ones that are gone tell me how to fix it.
  7. The submit button won't validate all data and save the data to the necessary arrays for processing and Total Households Surveyed will process the arrays and display the total households surveyed by state and then by county via HTML, Average Household Income will process the arrays and display the average household income by state and then by county via HTML, and Percentage Below Poverty will process the arrays and display the Percentage Below Poverty for each state and their counties via HTML.Poverty is based on Household of 1 and less than $12,000, Household of 2 and less than $18,000,Household of 3 and less than $25,000,Household of 4 and less than $30,000, Household of 5 or more and less than $40,000 this is my code: <?php $DateofSurvey = $_POST["Date of Survey"]; $CountyState = $_POST["County State"]; $NumberinHousehold = $_POST["Number in Household"]; $HouseholdyearlyIncome = $_POST["Household yearly Income"]; session_start(); value="<?PHP print$HouseholdyearlyIncome;?>" $_SESSION['Submit']=array(); array([StateWithCounty]=> array([0]=>'Hamilton, Oh',[1]=>'Butler, Oh',[2]=>'Boone, Ky',[3]=>'Kenton, Ky')); $Submit=count(StateWithCounty); for( $i=0; $i<$Submit ; $i++){ $TotalHouseholdsSurveyed += $Submit } $Submit=count(StateWithCounty); for( $i=0; $i<$Submit ; $i++){ $AverageHouseholdsIncome += $HouseholdyearlyIncome/$Submit } $Submit=count(StateWithCounty); for( $i=0; $i<$Submit ; $i++){ if (NumberinHousehold = 1 and HouseholdyearlyIncome < 12000 ){ $Submit=100% } elseif(NumberinHousehold = 2 and HouseholdyearlyIncome < 18000){ $Submit=100% } elseif(NumberinHousehold = 3 and HouseholdyearlyIncome < 25000){ $Submit=100% } elseif(NumberinHousehold = 4 and HouseholdyearlyIncome < 30000){ $Submit=100% } else{ $Submit=100% }}
×
×
  • 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.