+ 1

Anyone who can assist me with my assignment

its a web database where we are asked to populate drop-down tables retrive data from phpMyAdmin must be able to edit n delete mine just don't add data in the tables using the add form

4th Apr 2017, 6:55 PM
Ntabethemba Sydwell Ntshoza
Ntabethemba Sydwell Ntshoza - avatar
1 Resposta
0
Create a user on your SQL server which only has these Data permissions: "SELECT (for reading) UPDATE (for editing) DELETE" Create a database for it too. (remember the username and password, don't use root) Create your database PHP config file with your database details along with your new username and password you created. Should look something like: <?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "myDB"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT id, data"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "id: " . $row["id"]. " - Data: " . $row["firstname"]. " " . "<br>"; } } else { echo "0 results"; } $conn->close(); ?> Then you can instead of echoing the data, rather put them in your dropdown list using HTML and a while loop. PHP+HTML while ($row = $sql->fetch_assoc()){ echo "<option value=\"data\">" . $row['data'] . "</option>"; <option value="Data"><?php echo $row['data']; ?></option> and you can use this html+php combo file i found: <div id="contact_form"> <form action="contact_insert.php" method="post"> Firstname: <input type="text" name="firstname"> Lastname: <input type="text" name="surname"> Email: <input type="text" name="email"> <input type="submit" name="submit"> </form> </div> <?php if(isset($_POST['submit'])) { $username="root"; $password="password"; $server="127.0.0.1"; $database="eddiesdb"; $con = mysql_connect($server,$username,$password); $sql="INSERT INTO customer (FirstName, Surname, EmailAddress) VALUES ('$_POST[firstname]','$_POST[surname]','$_POST[email]')"; $a=mysql_query($sql);?> Hope this solution can help you.
10th Apr 2017, 11:25 PM
Jean-louis du Plessis
Jean-louis du Plessis - avatar