Question

I need help showing the first column of the table to show up exactly with the...

I need help showing the first column of the table to show up exactly with the mysql table into the php page. Is there a way to fix it ?

So I created a php form where the user enters the information. sand.truman.edu/~jyl6557/assignment5/hw5-dataentry.php . it asks for name, hometown, gender(only male and female) and status (freshman, sophmore, junior, senior). once it checks and passes through those tests, it would say added successfully and then show the links to add another enry or display the table.

here is the data entry page code:





Submission Form

// form with questions
function printform()
{
echo <<

Fill out the Information

Name:


Hometown:


Gender:


Year-status:











Info


END;
}
function process_form()
{
//local variables
$hostname='mysql.truman.edu';
$username='jyl6557';
$password='obookevo';
$db='jyl6557CS315';
$name=$_POST['Name'];
$hometown=$_POST['hometown'];
$gender=$_POST['gender'];
$status=$_POST['status'];


$connectDB=new PDO("mysql:host=$hostname;dbname=$db", $username,$password);

$sql_insert=$connectDB->prepare( "INSERT INTO People(Name, hometown, gender, status) VALUES (:Name, :hometown, :gender, :status)");
$sql_insert->bindParam(':Name',$name);
$sql_insert->bindParam(':hometown',$hometown);
$sql_insert->bindParam(':gender',$gender);
$sql_insert->bindParam(':status',$status);
$sql_insert->execute();

". $e->getMessage();

$connectDB=null;

echo <<

Added


ADD another entry
END;
}
//main program
if(isset($_POST['Submit']))
{
//matches any set of letters and specific words.
   $nameregrex="/^[A-z_\-]/";
   $hometownregrex="/^[A-z_\-]/";
   $genderregrex="/(M|f)emale|(M|m)ale/";
   $statusregrex="/(F|f)freshman|(S|s)ophmore|(J|j)unior|(S|s)enior/";
if(preg_match($nameregrex, $_POST['Name']) && preg_match($hometownregrex, $_POST['hometown']) && preg_match($genderregrex, $_POST['gender'])
&& preg_match($statusregrex, $_POST['status']))
{

echo << Add another entry


Display table
END;

process_form();
}
}
else
{
printform();
}

?>

the table that suppose to be like this:

Name hometown gender status
john kansas city male senior
bob matthews kirksville male freshman

here is the display table code pulled from mysql table:


Student Information Form



   
  

     
//sorts and displays data
function doGetAll($connectDB)
{
$sortby="name";
$sql="SELECT * from People order by $sortby";
$result=$connectDB->query($sql) or die ("mysql failed");
echo <<

List of students


END;

foreach ($result as $r)
{
extract($r);
print"

";
}
print"

name hometown gender year-status
$name $hometown $gender $status

";
echo <<

Successfully added


Add another information
END;
}
//connects to database
$hostname='mysql.truman.edu';
$username='jyl6557';
$password='obookevo';
$dbname='jyl6557CS315';
$connectDB= new PDO("mysql:host=$hostname;dbname=$dbname" ,$username,$password);

if(!$connectDB)
{
print "Error";
exit;
}
doGetAll($connectDB);

?>


   

0 0
Add a comment Improve this question Transcribed image text
Answer #1
<?php
echo "<table border='1' id= results>
<tr>
<th>FILEID</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Issue Date</th>
<th>Interest Rate</th>
<th>Terms</th>
<th>Balance Outstanding</th>
<th>Balance Outstanding</th>
<th>New Loan</th>
<th>Principal Repayment for $l_month</th>
<th>Principal Repaid</th>
<th>Balance Outstanding</th>
<th>Interest Payment for $l_month </th>
<th>INTEREST ACCUMULATED DURING FINNANCIAL YEAR</th>
</tr>";
while($row = mysql_fetch_array($result))
  {


  echo "<tr>"; 

    echo "<td>" . $row['app_file_id'] . "</td>";
    echo"<td>". $row['app_fname']."</td>";
    echo"<td>". $row['app_lname']."</td>";
    echo"<td>". $row['commit_date'] ."</td>";
    echo"<td>". $row['computer_interest'] ."</td>";
    echo"<td>". $row['loan_life'] ."</td>";
    echo"<td>". $row['avg(app_ln_amnt)'] ."</td>";
    echo"<td>". $row['Balance Outstanding'] ."</td>";
    echo"<td>". $row['New Loan'] ."</td>";
    echo"<td>". $row['SUM(r.receipt_on_principal)'] ."</td>";
    echo"<td>". $row['Principal Repaid'] ."</td>";
    echo"<td>". $row['avg(app_amnt_owed)'] ."</td>";    
    echo"<td>". $row['SUM(r.receipt_on_interest)'] ."</td>";
    echo"<td>". $row['Interest Accumilated'] ."</td>";
  echo "</tr>";
  }
echo "</table>";
?>
<button onclick="javascript:window.print();"></button>
Add a comment
Know the answer?
Add Answer to:
I need help showing the first column of the table to show up exactly with the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • How can I print the Database table in PHP please ? here I have form for name and email, also I have php code that allow...

    How can I print the Database table in PHP please ? here I have form for name and email, also I have php code that allow user to add his name and email to my database, all I need to print my final database when the user click on submit. <form action="" method="post"> <label>Name :</label> <input type="text" name="name" required="required" placeholder="Please Enter Name"/><br /><br /> <label>Email :</label> <input type="email" name="email" required="required" /><br/><br /> <input type="submit" value=" Submit " name="submit"/><br /> </form>...

  • For this code below, I need to add the form information to mysql when I click...

    For this code below, I need to add the form information to mysql when I click on submit, at the same time when I click on submit I need to move to another page like Welcome.php WITH NOTE THAT THE ENTERED INFORMATION NOW ALREADY IN DATABASE how can I male that with my code below? THANKS ................................................................................................................................................   <form method="POST"> <div class="container">    <label for="fname"><b>First Name</b></label> <input type="text" placeholder="Enter First Name" name="fname" required> <label for="lname"><b>Last Name</b></label> <input type="text" placeholder="Enter Last Name"...

  • LANGUAGE JAVASCRIPT, PHP Need help with PHP and ajax code. The user needs to login but,...

    LANGUAGE JAVASCRIPT, PHP Need help with PHP and ajax code. The user needs to login but, I keep getting an error that I coded "Wrong username and password!" ***PLEASE DONT GIVE ME A NEW CODE THAT IS NOWHERE NEAR THE CODE I SUBMITTED***** PLEASE LOOK AT THE CODE AND SEE ANY ISSUES login.html <!DOCTYPE html> <html> <head> <title>login popup</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <style type="text/css"> body { background-color: white; } </style> </head> <body> <center> <h1 style="text-align: center;"> Login </h1> <form>             Login ID:...

  • I need help please to add function for clean up any inputs form that we receive from the users for this code below : &lt...

    I need help please to add function for clean up any inputs form that we receive from the users for this code below : <?php session_start(); // initializing variables $fname = ""; $lname = ""; $address = ""; $city = ""; $state = ""; $zip = ""; $email = ""; $phone = ""; $errors = array(); // connect to the database $db = mysqli_connect("localhost","root","password","db"); // REGISTER USER if (isset($_POST['reg_user1'])) { // receive all input values from the form $fname =...

  • PHP Programming In this project, you will create a Web page that allows visitors to your...

    PHP Programming In this project, you will create a Web page that allows visitors to your site to sign a guest book that is saved to a database. Create a new document in your text editor and type the <!DOCTYPE> declaration, <html> element, document head, and <body> element. Use the strict DTD and “Guest Book” as the content of the <title> element. Add the following text and elements to the document body: <h2>Enter your name to sign our guest book</h2>...

  • <html> <!--This is the form for an instructor to upload a file having the grade of...

    <html> <!--This is the form for an instructor to upload a file having the grade of students in a class--> <body> <h2>Upload Student Grade</h2> <form action="1.php" method="POST" enctype="multipart/form-data">    Instructor's First Name:<input type="text" name="first"><br><br>    Instructor's Last Name: <input type="text" name="last"><br><br>      Instructor's Department Name:<input type="text" name="department"><br><br>          Upload student grade: <input type="file" name="image" /><br><br> <input type="submit"/> </form>    </body> </html> //***************************************************Q1****************************************************************************      /*(((( Q1)))). (18 points) Add the code below that *   uploads the file containing the students'...

  • PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create...

    PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create the schema, and package. 2. Create users x1 and x2 who are the participants in the auction. They will need acces to the package. 3. Bid on the same item and record your observations. Verify all scenarios. Upload the files with the missing code and a detailed sample run. AUCTION OWNER.TXT SQL> conn / as sysdba Connected. SQL> drop user xyz cascade; User dropped....

  • Could anyone help add to my python code? I now need to calculate the mean and...

    Could anyone help add to my python code? I now need to calculate the mean and median. In this programming assignment you are to extend the program you wrote for Number Stats to determine the median and mode of the numbers read from the file. You are to create a program called numstat2.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The...

  • Need help, numbers 3-6 please show work. and fill out table of chemicals for all chemical...

    Need help, numbers 3-6 please show work. and fill out table of chemicals for all chemical used. calculate mmol in the table as well show work please and each of these must be listed in its own row. There are 10 column headings: IUPAC name OR common name, structure, CAS number (Chemical Abstract Service number) molecular mass, melting point (if applicable), boiling point (if applicable), solubility (in water, if applicable), density, amounts to be used in the experiment, and the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT