Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Chisels: Crecsent Wrench: Hedge Clippers: Shipping Information First Name: Last

ID: 3859687 • Letter: C

Question






Chisels:




Crecsent Wrench:




Hedge Clippers:



Shipping Information

First Name:



Last Name:



Shipping Address

Street:



CITY:



Zipcode:

????????????

?>


Payment Method:

Visa

Master Card

American express

Part 1; From databases to forms: Read Database Access with PHP. Copy your form from Lab Exercise6 to 17p1.php and change it to read the states from a database table instead of putting them into a PHP array yourself. The database is named weblab and the table of states is named statet. The table was created as follows: - CREATE TABLE state t state abbr char (2) PRIMARY KEY state name char (20). Display the state name in the drop-down, but transmit the state abbreviation through the form. You do this by using a value attribute on the Koption value-"EL"loridax/option Georgiac/option> toption value-"IN">Tennesseet/option>

Explanation / Answer

1. Connect to the data base using any DBMS packages. Best suitable package for students is phpMyadmin.

2. Write code for connecting to the database.

3.Write query to retrieve data from database.

4. Execute query.

5. Display the result.

.........................Here is the sample code for the same........................

<?php

/*** mysql hostname ***/

$hostname = 'localhost';

/*** mysql username ***/

$username = 'username';

/*** mysql password ***/

$password = 'password';

// Create connection

$con=mysqli_connect(host,username,password,dbname);

// Check connection

if (mysqli_connect_errno())

{

echo "Failed to connect to MySQL: " . mysqli_connect_error();

}

else

{

$query="SELECT state_abbr, state_name from state_t ORDER BY state_name";

$result = $conn->query($queryl);

if ($result->num_rows > 0)

{
    // output data of each row
    while($row = $result->fetch_assoc())

{
        echo $row["state_name"]; // displaying state name from table
    }

}

?>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote