<?php
$msg="";
$image1="";
$image1_err="";
//if upload button is pressed
if(isset($_POST['upload'])){
$target="images/".basename($_FILES['image']['name']);
$db=mysqli_connect("localhost","root","","categories");
$image=$_FILES['image']['name'];
$text=$_POST['text'];
if(isset($_POST['electro'])){
$sql="INSERT INTO electronic(image,text) VALUES ('$image','$text')";
mysqli_query($db,$sql);
}
//move image to a file
if(move_uploaded_file($_FILES['image']['tmp_name'],$target)){
$msg="Image uploaded successfully";
}else{
$msg="There was a problem uploading image";
}
}
?> <!DOCTYPE html> <html> <head> <title>Image Upload</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div id="content"> <?php
$db=mysqli_connect("localhost","root","","categories");
$sql="SELECT * FROM electronic";
$result=mysqli_query($db,$sql);
while($row =mysqli_fetch_array($result)){
echo "<div id='img_div'>";
echo "<img src='images/".$row['image']."'>";
echo "<p>" .$row['text']."</p>";
echo "</div>";
}
?>
Tay_2
0
Newbie Poster
Recommended Answers
Jump to PostPlease add what line you think the issue is at and "what is the issue" to this. As it stands your post looks to be a how-to.
All 4 Replies
rproffitt
2,580
"Nothing to see here."
Moderator
Tay_2
0
Newbie Poster
alan.davies
185
What's this?
rproffitt
commented:
"Welcome Little Bobby Tables"
+15
alan.davies
185
What's this?
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.