Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions forstudents.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html>
<body>
<?php
$servername="localhost";
$susername="root";
$spassword="";
$sdbname="nsbmedge";

// Create connection
$con = mysqli_connect("$servername", "$susername","$spassword", "$sdbname");


// Check connection
if (!$con) {
die("Connection failed: " . mysqli_connect_error());
}

$sql = "SELECT * FROM `foods`WHERE (`favailability`='1')";
$result = mysqli_query($con, $sql);


echo "<table border=1>";


if (mysqli_num_rows($result) > 0)
{
// output data of each row
while($row = mysqli_fetch_assoc($result))
{
echo "<tr>";
echo "<td> " . $row["fid"]. " </td> <td> " . $row["fname"]. "</td> <td> " . $row["fdescription"]. "</td>";
echo "<td> ";?> <img src="uploads/<?php echo $row['fimage']; ?>" width="100px" height="100px" style="border:1px solid #333333;">
<?php

}
} else {
echo "0 results";
}

mysqli_close($con);
?>
</body>
</html>
90 changes: 90 additions & 0 deletions sql/nsbmedge.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
-- phpMyAdmin SQL Dump
-- version 4.9.0.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Dec 24, 2019 at 02:30 PM
-- Server version: 10.3.16-MariaDB
-- PHP Version: 7.3.7

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `nsbmedge`
--
CREATE DATABASE IF NOT EXISTS `nsbmedge` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `nsbmedge`;

-- --------------------------------------------------------

--
-- Table structure for table `foods`
--

DROP TABLE IF EXISTS `foods`;
CREATE TABLE `foods` (
`fid` int(4) NOT NULL,
`fname` text NOT NULL,
`fdescription` text NOT NULL,
`fimage` longblob NOT NULL,
`favailability` int(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `login`
--

DROP TABLE IF EXISTS `login`;
CREATE TABLE `login` (
`userid` int(11) NOT NULL,
`username` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `foods`
--
ALTER TABLE `foods`
ADD PRIMARY KEY (`fid`);

--
-- Indexes for table `login`
--
ALTER TABLE `login`
ADD PRIMARY KEY (`userid`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `foods`
--
ALTER TABLE `foods`
MODIFY `fid` int(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=26;

--
-- AUTO_INCREMENT for table `login`
--
ALTER TABLE `login`
MODIFY `userid` int(11) NOT NULL AUTO_INCREMENT;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
88 changes: 88 additions & 0 deletions upload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

$servername="localhost";
$susername="root";
$spassword="";
$sdbname="nsbmedge";

$db = mysqli_connect("$servername", "$susername","$spassword", "$sdbname");



error_reporting("0");


if(isset($_POST['submit'])){

//Get image name

$image = $_FILES['image']['name'];
//Get text
$fname= $_POST['fname'];
$fdescription= $_POST['fdescription'];
$favailability= $_POST['favailability'];


//image file directory

$move=move_uploaded_file($_FILES["image"]["tmp_name"],"uploads/". $_FILES["image"]["name"]);




//insert query


$sql = "INSERT INTO foods(fimage,fname,fdescription,favailability) values ('$image','$fname','$fdescription','$favailability')";


//excute query


mysqli_query($db,$sql);


if($move)


{


echo " successfully uploaded";


}else{


echo "Failed to upload";


}


}



?>
<html>
<head>


</head>
<body>
<form action="upload.php" method="POST" enctype="multipart/form-data">
name
<input type="text" name="fname"> <br>
description
<input type="text" name="fdescription"> <br>
photo
<input type="file" name="image"> <br>
availability
<input type="text" name="favailability"> <br>
<button type="submit" name="submit">POST</button>


</form>
</body>
</html>
Binary file added uploads/legal-sea-foods-logan.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added uploads/triple-chocolate-cake-4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.