当我检索输入的表单数据时,数据库中已经存在的数据也会与输入的数据一起打印。在多组输入字段中多次输入时,出现另一个错误。插入数据时出错。您的SQL语法有误;请查看与您的MariaDB服务器版本相对应的手册以获取正确的语法。
<?php
$con = mysqli_connect("localhost", "root", "", "cv-builder1")or die($mysqli_error($con));
$sql="insert into fields (`name`, `email`, `profession`, `location`, `content`) values('".$_POST['name']."','".$_POST['email']."','".$_POST['profession']."','".$_POST['place']."','".$_POST['summary']."')";
mysqli_query($con,$sql) or die("Error inserting data.".mysqli_error($con));
if(isset($_POST['site'])){
$site = $_POST['site'];
$url = $_POST['url'];
$query = '';
for($i = 0; $i<count($site); $i++){
$site_name = mysqli_real_escape_string($con, $site[$i]);
$url_name = mysqli_real_escape_string($con, $url[$i]);
if ($site_name !='' && $url_name !=''){
$query .='INSERT INTO url (`site`, `http`) VALUES ("'.$site_name.'", "'.$url_name.'")';
}
}
mysqli_query($con, $query) or die("Error inserting data.".mysqli_error($con));
}
if(isset($_POST['school'])){
$ins = $_POST['school'];
$qual = $_POST['edu'];
$date = $_POST['date'];
$note = $_POST['desc'];
$query ='';
for($i=0; $i<count($ins); $i++){
$ins_name = mysqli_real_escape_string($con,$ins[$i]);
$profession = mysqli_real_escape_string($con,$qual[$i]);
$dateto = mysqli_real_escape_string($con,$date[$i]);
$content = mysqli_real_escape_string($con,$note[$i]);
if($ins_name !='' && $profession !='' && $dateto !='' && $content !=''){
$query .='INSERT INTO education (`name`, `qualification`, `date`, `note`) VALUES ("'.$ins_name.'", "'.$profession.'", "'.$dateto.'", "'.$content.'")';
}
}
mysqli_query($con,$query) or die("Error inserting data.".mysqli_error($con));
}
if(isset($_POST['emp'])){
$emp = $_POST['emp'];
$title = $_POST['job'];
$date1 = $_POST['date1'];
$note1 = $_POST['desc1'];
$query ='';
for($i=0; $i<count($emp); $i++){
$emp_name=mysqli_real_escape_string($con,$emp[$i]);
$title_name=mysqli_real_escape_string($con,$title[$i]);
$dateto1=mysqli_real_escape_string($con,$date1[$i]);
$content1=mysqli_real_escape_string($con,$note1[$i]);
if($emp_name !='' && $title_name !='' && $dateto1 !='' && $content1 !=''){
$query .='INSERT INTO experience (`empolye`, `job`, `date`, `note`) VALUES ("'.$emp_name.'", "'.$title_name.'", "'. $dateto1.'", "'.$content1.'")';
}
}
mysqli_query($con,$query) or die("Error inserting data.".mysqli_error($con));
}
?>
<div id="line">
<hr style="margin-top:20px;" color="#009933" size="8" width="90%"/>
</div>
<div id="total">
<div>
<?php
$query="SELECT * FROM `fields`";
$result=mysqli_query($con,$query) or die("Error fetching data.".mysqli_error($con));
$details=mysqli_fetch_assoc($result);
mysqli_free_result($result);
?>
<div>
<h1 id="my"><?php echo $details['name']; ?></h1>
</div>
<div>
<h2 id="made"><?php echo $details['profession']; ?></h2>
</div>
<div>
<pre id="text"><?php echo $details['location']; ?></pre>
</div>
<div>
<p class="email"><?php echo $details['email']; ?></p>
</div>
<h2>Reasume Contant</h2>
<div>
<p id="content"><?php echo $details['content']; ?></p>
</div>
</div>
<h2>URL</h2>
<div class="url">
<?php
$query="SELECT * FROM `url`";
$result=mysqli_query($con,$query) or die("Error fetching data.".mysqli_error($con));
while($http=mysqli_fetch_assoc($result))
{
?>
<ul style="list-style-type:none;padding-left:0%;">
<li><?php echo $http['site']; ?></li>
<li><?php echo $http['http']; ?></li>
</ul>
<?php
}
mysqli_free_result($result);
?>
</div>
<h2>Education</h2>
<div class="edu">
<?php
$query="SELECT * FROM `education`";
$result=mysqli_query($con,$query) or die("Error fetching data.".mysqli_error($con));
while($edudetails=mysqli_fetch_assoc($result))
{
?>
<ul style="list-style-type:none;padding-left:0%;">
<li><?php echo $edudetails['name']; ?></li>
<li><?php echo $edudetails['qualification']; ?></li>
<li><?php echo $edudetails['date']; ?></li>
<li><?php echo $edudetails['note']; ?></li>
</ul>
<?php
}
mysqli_free_result($result);
?>
</div>
<h2>Experience</h2>
<div>
<?php
$query="SELECT * FROM `experience`";
$result=mysqli_query($con,$query) or die("Error fetching data.".mysqli_error($con));
while($empdetails=mysqli_fetch_assoc($result))
{
?>
<ul style="list-style-type:none;padding-left:0%;">
<li><?php echo $empdetails['empolye']; ?></li>
<li><?php echo $empdetails['job']; ?></li>
</ul>
<dd>
<li><?php echo $empdetails['date']; ?></li>
<li><?php echo $empdetails['note']; ?></li>
</dd>
<?php
}
mysqli_free_result($result);
?>
</div>
</div>