php - Cannot fetch the recent added data from database -
i created data through insert page data inserted using mysql. when try fetch new inserted data, won't fetch data.
for example:
insert bag(bid,bookno,name) values ('','$bn','$n'); my data supposedly:
bid bookno name 1 23 mystery 2 56 mystery 3 89 mysteryy when fetch name column, fetches name="mystery" smoothly, cannot fetch name ="mysteryy" data inserted database.
my fetch query is...
select * bag name='$name'; where $name=$_post['nam'];
this html code:
<td><input type="checkbox" name="chk[]"/></td> <td><input type="text" name="bookno[]" id="bookno" /></td> <td><input type="text" name="nam[]" id="nam" /></td> the php insert code:
foreach($_post['nam'] $row=>$pro) { if($pro!="") { $n=$pro; $bn=$_post['bookno'][$row]; } } $s=insert bag(bid,bookno,name) values ('','$bn','$n');
try using like in select statement. (and converting code mysqli):
$name=mysqli_real_escape_string($yourconnection,$_post['nam']); /* practice using mysqli real escape string can prevent of sql injection */ $result=($yourconnection,"select * bag name '%$name%'");
about $yourconnection variable:
$yourconnection=mysqli_connect("yourhost","username","password","yourdatabase"); if(mysqli_connect_errno()){ echo "error".mysqli_connect_error(); }
Comments
Post a Comment