Jump to content

maideen

Members
  • Content Count

    36
  • Joined

  • Last visited

Community Reputation

0 Neutral

About maideen

  • Rank
    Member
  1. Hi I have an issue to insert data from dropdown to mysql. It is inserting the partial data to database Example: if selection is Account Dept, but inserted only Account. missing Dept if selection is Non Active, inserted only Non. missing Active. whatever coming after space, it cannot be inserted. It happens only in dropdown control. In Database, using varchar(30) for column Pls advice where I did wrong. Thank you Maideen Here is my HTML code <label>Status</label> <select class="form-control" data-placeholder="Choose a Category" name="status"> <option></option> <?php $sql = "select * from tbl_parameter where paramhead ='STATUS' order by paramdetails"; $stmt = $pdo->prepare($sql); $stmt->execute(); while ($row = $stmt->fetch()) { $optvalue = $row['paramdetails']; print '<option value ='.$optvalue.'>' .$row['paramdetails']. '</option>'; } ?> </select> php code if(isset($_POST['add'])) { if($_SERVER["REQUEST_METHOD"] == "POST") { $staffid =$_POST['staffid']; $staffname =$_POST['staffname']; $gender =$_POST['gender']; $department=$_POST['department']; $emailid=$_POST['emailid']; $hpno=$_POST['hpno']; $address=$_POST['address']; $city=$_POST['city']; $state=$_POST['state']; $country=$_POST['country']; $status=$_POST['status']; $createdby=$_COOKIE['username']; $time = strftime("%X"); $date = strftime("%B %d,%Y"); $createdon = date("Y-m-d H:i:s"); $terminal=$_COOKIE['terminal']; $bool = true; $sql="insert into tbl_staff_master(staffid,staffname,gender,department,emailid,hpno,address,city,state,country,status,createdby,createdon,terminal) values ('$staffid','$staffname','$gender','$department','$emailid','$hpno','$address','$city','$state','$country','$status','$createdby','$createdon','$terminal')"; $stmt=$pdo->prepare($sql); $stmt->execute(); $pdo = null; print '<script>alert("Saved");</script>'; header("location:staff_add.php"); } }
  2. Hi I am new. I am using Bootstrap css. I have an issue to display image with data type BLOB, Really I don't know how to do this. Pls advise me how to do this. Thanks maideen My php insert Code <?php require_once '../inc/config.php'; if(isset($_POST['add'])) { if($_SERVER["REQUEST_METHOD"] == "POST") { $sid =$_POST['sid']; $sname =$_POST['sname']; $nric=$_POST['nric']; $gender=$_POST['gender']; $dob=$_POST['dob']; $courseid=$_POST['courseid']; $pname=$_POST['pname']; $emailid=$_POST['emailid']; $hpno=$_POST['hpno']; $homeno=$_POST['homeno']; $offno=$_POST['offno']; $emergencyno=$_POST['emergencyno']; $address=$_POST['address']; $city=$_POST['city']; $state=$_POST['state']; $country=$_POST['country']; $hname=$_POST['hname']; $alergies=$_POST['alergies']; $milkpowder=$_POST['milkpowder']; $specialfoods=$_POST['specialfoods']; $specactivy1=$_POST['specactivy1']; $specactivy2=$_POST['specactivy2']; $specactivy3=$_POST['specactivy3']; $specactivy4=$_POST['specactivy4']; $simage=$_POST['simage']; $createdby =$_POST['username']; $time = strftime("%X"); $date = strftime("%B %d,%Y"); //$createdon= $date; $createdon = date("Y-m-d H:i:s"); $bool = true; $sql="insert into tbl_student_master(sid,sname,nric,gender,dob,courseid,pname,emailid,hpno,homeno,offno,emergencyno,address,city,state,country,hname,alergies,milkpowder, specialfoods,specactivy1,specactivy2,specactivy3,specactivy4,simage,createdby,createdon) values ('$sid','$sname','$nric','$gender','$dob','$courseid','$pname','$emailid','$hpno','$homeno','$offno','$emergencyno','$address','$city','$state','$country', '$hname','$alergies','$milkpowder','$specialfoods','$specactivy1','$specactivy2','$specactivy3','$specactivy4','$simage','$createdby','$createdon')"; $stmt=$pdo->prepare($sql); $stmt->execute(); $pdo = null; print '<script>alert("Saved");</script>'; header("location:../student/student_add.php"); } } Insert HTML <div class="col-md-9"> <div class="fileinput fileinput-new" data-provides="fileinput"> <div class="fileinput-new thumbnail" style="width: 200px; height: 150px;"> <img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&text=no+image" alt="" /> </div> <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"> </div> <div> <span class="btn default btn-file"> <span class="fileinput-new"> Select image </span> <span class="fileinput-exists"> Change </span> <input type="file" name="simage"> </span> <a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput"> Remove </a> </div> </div> </div> My display php code <?php if($_SERVER["REQUEST_METHOD"] == "GET") { $id=$_GET['id']; $sql ="Select * from tbl_student_master where id ='$id'"; $stmt = $pdo->prepare($sql); $stmt->execute(); while ($row = $stmt->fetch()) { $id =$row['id']; $sid =$row['sid']; $sname =$row['sname']; $nric=$row['nric']; $gender=$row['gender']; $dob=$row['dob']; $courseid=$row['courseid']; $pname=$row['pname']; $emailid=$row['emailid']; $hpno=$row['hpno']; $homeno=$row['homeno']; $offno=$row['offno']; $emergencyno=$row['emergencyno']; $address=$row['address']; $city=$row['city']; $state=$row['state']; $country=$row['country']; $hname=$row['hname']; $alergies=$row['alergies']; $milkpowder=$row['milkpowder']; $specialfoods=$row['specialfoods']; $specactivy1=$row['specactivy1']; $specactivy2=$row['specactivy2']; $specactivy3=$row['specactivy3']; $specactivy4=$row['specactivy4']; $simage=$row['simage']; } } ?> My Display HTML <div class="col-md-9"> <div class="fileinput fileinput-new" data-provides="fileinput"> <div class="fileinput-new thumbnail" style="width: 200px; height: 150px;"> <img src="" alt="" /> <?php echo $simage; ?> </div> <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"></div> <div> <span class="btn default btn-file"> <span class="fileinput-new"> Select image </span> <span class="fileinput-exists"> Change </span> <input type="file" name="simage"> </span> <a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput"> Remove </a> </div> </div> </div>
  3. Hi I could not load data into input text and select option control. I don't know where i did wrong. Pls advice me Thank you in advence maideen <?php require_once '../inc/header.php'; ?> <?php if($_SERVER["REQUEST_METHOD"] == "GET") { $id=$_GET['id']; $sql ="Select * from tbl_parameter where id ='$id'"; $stmt = $pdo->prepare($sql); $stmt->execute(); while ($row = $stmt->fetch()) { $paramhead =$row['paramhead']; $paramdetails =$row['paramdetails']; $id =$row['id']; // below is display information in page. It is OK echo "id entered is :",$id,"<br>"; echo "paramHead entered is :",$paramhead,"<br>"; echo "Param details entered is :",$paramdetails,"<br>"; } } ?> <div class="portlet light bordered"> <div class="portlet-title"> <div class="caption"> <i class="icon-social-dribbble font-green"></i> <span class="caption-subject font-green bold uppercase">Update Parameter</span> </div> </div> <div class="portlet-body"> <form action="../classes/cls.parameter.php" method="POST"> <div class="form-group"> <label for="default" class="control-label">Parameter Details</label> <input id="paramdetails" type="text" class="form-control" placeholder="Parameter Details" name="paramdetails" values ="<?php echo $paramdetails; ?>" > </div> <div class="form-group"> <label for="single" class="control-label">Parameter head</label> <select id="paramhead" name="paramhead" class="form-control select2" > <option>-- Select --</option> <?php $sql = "select * from tbl_paramhead order by paramhead"; $stmt = $pdo->prepare($sql); $stmt->execute(); while ($row = $stmt->fetch()) { $optvalue = $row['paramhead']; print '<option value ='.$optvalue.'>' .$row['paramhead']. '</option>'; //echo '<option value ='.$row['paramhead'].'>' .$row['paramhead']. '</option>'; } ?> </select> </div> <div class="form-actions"> <button type="submit" class="btn green uppercase btn btn-danger mt-ladda-btn ladda-button" data-style="zoom-out" name="add">Submit</button> </div> </form> </div> </div> <?php require_once '../inc/footer.php'; ?>
  4. Mr.Pravin S I have checked as per advice, data is not posting only from dropdown control and normal text control can be posted. Dropdown control fetch data from database table. Have you any advice, pls..... <select id="paramhead" name="paramhead" class="form-control select2" > <option>-- Select --</option> <?php $sql = "select * from tbl_paramhead order by paramhead"; $stmt = $pdo->prepare($sql); $stmt->execute(); while ($row = $stmt->fetch()) { $optvalue = $row['paramhead']; //print '<option value ='.$optvalue.'>' .$row['paramhead']. '</option>'; echo '<option value ='.$row['paramhead'].'>' .$row['paramhead']. '</option>'; } //$pdo = null; ?> </select>
  5. thanks for reply Mr.Pravin I have added echo '<option value ='.$row['paramhead'].'>' .$row['paramhead']. '</option>'; But Still same, cannot insert into data table Where did i do mistake> Pls advice me Thank you again
  6. Hi I am new in PHP. I have used dropdown to bind with my sql data. It is ok But I could not insert data into table only from dropdown. Other controls like text can be inserted. I have given code below. Pls advise me. Maideen <?php require_once '../inc/header.php'; ?> <div class="portlet light bordered"> <div class="portlet-title"> <div class="caption"> <i class="icon-social-dribbble font-green"></i> <span class="caption-subject font-green bold uppercase">Parameter</span> </div> </div> <form class="forget-form" action="../classes/cls.parameter.php" method="POST"> <div class="portlet-body"> <div class="form-group"> <label for="default" class="control-label">Parameter Details</label> <input id="default" type="text" class="form-control" placeholder="Parameter Details" name="paramdetails"> </div> <div class="form-group"> <label for="single" class="control-label">Parameter head</label> <select id="paramhead" class="form-control select2" name="paramhead"> <option>-- Select --</option> <?php $sql = "select * from tbl_paramhead order by paramhead"; $stmt = $pdo->prepare($sql); $stmt->execute(); while ($row = $stmt->fetch()) { echo '<option value>' .$row['paramhead']. '</option>'; } ?> </select> </div> </div> <div class="form-actions"> <button type="submit" class="btn green uppercase btn btn-danger mt-ladda-btn ladda-button" data-style="zoom-out" name="paramhead">Submit</button> </div> </form> </div> <?php require_once '../inc/footer.php'; ?> <?php require_once '../inc/config.php'; if(isset($_POST['paramhead'])) { if($_SERVER["REQUEST_METHOD"] == "POST") { $paramhead =$_POST['paramhead']; $paramdetails =$_POST['paramdetails']; $bool = true; $sql="insert into tbl_parameter(paramhead,paramdetails) values ('$paramhead','$paramdetails')"; $stmt=$pdo->prepare($sql); $stmt->execute(); $pdo = null; print '<script>alert("Saved");</script>'; print '<script>window.location.assign("../admin/parameter.php");</script>'; } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.