vinod_vsd Posted March 30, 2012 Share Posted March 30, 2012 <?php $where=""; if(isset($_POST['courier_no'])) { $var2 = explode(",",$var); $where=" AND A.courier_no= ". $_POST['courier_no']; } ?> // here i get courier_no. and i want to display details if no exist in daatabase.. please help in this regards $sql=("SELECT A.courier_id, A.courier_no , A.sender_name ,A.saddress, B.location_name AS Sender_location , A.reciever_name ,A.raddress , C.location_name AS Reciever_location FROM courier_detail A,location B,location C WHERE A.location2 = B.location_id AND A.location_id = C.location_id AND A.isdelete=0 ".$where) ; // using this query i want to display record set . $result =mysql_query($sql); while($row = mysql_fetch_array($result)) { // here i fetch all details } Link to comment https://forums.phpfreaks.com/topic/260001-how-to-check-entries-exist-in-mysql-database-or-not/ Share on other sites More sharing options...
trq Posted March 30, 2012 Share Posted March 30, 2012 You forgot to ask a question. Link to comment https://forums.phpfreaks.com/topic/260001-how-to-check-entries-exist-in-mysql-database-or-not/#findComment-1332647 Share on other sites More sharing options...
AyKay47 Posted March 30, 2012 Share Posted March 30, 2012 can you please post all of the relevant code, I don't quite understand what your issue is. Link to comment https://forums.phpfreaks.com/topic/260001-how-to-check-entries-exist-in-mysql-database-or-not/#findComment-1332648 Share on other sites More sharing options...
vinod_vsd Posted March 30, 2012 Author Share Posted March 30, 2012 <form action="courier_list.php" method="post" > <table cellpadding="0" cellspacing="0" border="0" style="margin:15px 0 0 35px" > <tr> <td width="147" style="height:19px"><label for="Serach"> <input type="text" name="courier_no" id="courier_no" style="width:133px; height:19px; border-style:double; border-width:1px; border-color:#AFAFAF" value="Search Your Tracking ID"></label> </td> <td width="55" style="height:19px"><input type="image" name="submit" src="images/search.jpg" ></td> </tr> </table></form> <!--- from here i send courier_no to courier_list.php Link to comment https://forums.phpfreaks.com/topic/260001-how-to-check-entries-exist-in-mysql-database-or-not/#findComment-1332653 Share on other sites More sharing options...
AyKay47 Posted March 30, 2012 Share Posted March 30, 2012 you still have not explained your logic. Link to comment https://forums.phpfreaks.com/topic/260001-how-to-check-entries-exist-in-mysql-database-or-not/#findComment-1332655 Share on other sites More sharing options...
vinod_vsd Posted March 30, 2012 Author Share Posted March 30, 2012 i get courier_no in courier_list.php by POST... now i want to display of records of courier_no which i get in $_POST...if record exist... actually i m new with php and mysql. Link to comment https://forums.phpfreaks.com/topic/260001-how-to-check-entries-exist-in-mysql-database-or-not/#findComment-1332659 Share on other sites More sharing options...
AyKay47 Posted March 30, 2012 Share Posted March 30, 2012 I will post the code that was pm'ed to me for other to see: <?php include("top.php");?> <?php $where=""; if(isset($_POST['courier_no'])) { $var=$_POST['courier_no']; $where=" AND A.courier_no LIKE '". $_POST['courier_no'] ."%'"; } ?> <tr> <td class="content" valign="top"> <table width="100%" border="0" align="right"> <tr bordercolordark="#FF0000"> <td align="center" colspan="2"> <h2 align="center"><font color="#FF0033" size="5" face="Courier New">Your Courier Details</font></h2> </td> </tr> <table width="99%" align="right" style="border:solid 1px" class="nav_sel"> <?php include("connect.php"); ?> <?php $courier_id=0; $sql=("SELECT A.courier_id, A.courier_no , A.sender_name ,A.saddress, B.location_name AS Sender_location , A.reciever_name ,A.raddress , C.location_name AS Reciever_location FROM courier_detail A,location B,location C WHERE A.location2 = B.location_id AND A.location_id = C.location_id AND A.isdelete=0 ".$where) ; $result =mysql_query($sql); while($row = mysql_fetch_array($result)) { $courier_id=$row['courier_id']; echo "<tr>"; echo"<td height='31' colspan='1' align='center'><b>Courier No :</b></td>"; echo"<td width='117' colspan='0' bgcolor='#dce4ff'>". $row['courier_no'] ."</td>"; echo "<td width='117' height='29'></td>"; echo "<td colspan='0' height='30' bgcolor='#dce4ff'></td>"; echo "</tr>"; echo "<tr>"; echo "<td width='100' height='34'><b> Sender Name :</b></td>"; echo "<td width='117' bgcolor='#dce4ff'>". $row['sender_name'] ."</td>"; echo "<td width='110'> <b>Reciever Name :</b></td>"; echo "<td width='117' bgcolor='#dce4ff'>". $row['reciever_name'] ."</td>"; echo "</tr>"; echo "<tr>"; echo "<td height='29'><b>Sender Address :</b></td>"; echo "<td bgcolor='#dce4ff'>". $row['saddress'] ."</td>"; echo "<td><b>Reciever Address :</b></td>"; echo "<td bgcolor='#dce4ff'>". $row['raddress'] ."</td>"; echo "</tr>"; echo "<tr>"; echo "<td height='29' width='135'><b>Sender Location :</b></td>"; echo "<td width='70' bgcolor='#dce4ff'>". $row['Reciever_location'] ."</td>"; echo "<td width='135'><b>Reciever Location :</b></td>"; echo "<td bgcolor='#dce4ff'>". $row['Sender_location'] ."</td>"; echo "</tr>"; ?> <?php echo "</td >" ; echo "</tr>"; } echo "</table>";?><br /> <h2 align="center"><font color="#FF0000" size="5" face="Courier New">Courier Tracking Details</font></h2> <table width="99%" border="0"align="right" style="border:solid 1px" class="nav_sel"> <?php $sql ="SELECT A.remark, A.recieve_date, A.transit_id, B.location_name AS Forward_To, D.type_name AS Courier_Type,E.courier_no AS Courier_No, C.status_name AS Status FROM transit A, location B,STATUS C,TYPE D,courier_detail E WHERE A.location_id = B.location_id AND A.status_id = C.status_id AND A.type_id = D.type_id AND A.courier_id=E.courier_id AND E.courier_id=".$courier_id." order by recieve_date asc"; $result1 =mysql_query($sql); while($row1 = mysql_fetch_array($result1)) { echo "<tr>"; echo "<td width='110' height='29'><b>Status :</b></td>"; echo "<td width='117' bgcolor='#dce4ff'>". $row1['Status'] ."</td>"; echo "<td width='117' height='29'><b>Recieve Date :</b></td>"; echo "<td width='117' bgcolor='#dce4ff'>". $row1['recieve_date'] ."</td>"; echo "</tr>"; echo "<tr>"; echo "<td width='117' height='29'><b>Forward Towards :</b></td>"; echo "<td width='70' bgcolor='#dce4ff'>" . $row1['Forward_To'] ."</td>"; echo "<td width='117' height='29'><b>Courier Type :</b></td>"; echo "<td bgcolor='#dce4ff'>". $row1['Courier_Type'] ."</td>"; echo "</tr>"; echo "<tr>"; echo "<td width='117' height='29'><b>Remark :</b></td>"; echo "<td colspan='0' height='30' bgcolor='#dce4ff'>". $row1['remark'] ."</td>"; echo "<td width='117' height='29'></td>"; echo "<td colspan='0' height='30' bgcolor='#dce4ff'></td>"; echo "</tr>"; ?> <?php echo "</td >" ; echo "</tr>"; } echo "</table>";?> <?php mysql_close($con); } ?> </td> <?php include("footer.php"); ?> ///////// the whole file is my courier_list.php add some debugging to your script to see what is happening: $sql = "SELECT A.courier_id, A.courier_no , A.sender_name ,A.saddress, B.location_name AS Sender_location , A.reciever_name ,A.raddress , C.location_name AS Reciever_location FROM courier_detail A,location B,location C WHERE A.location2 = B.location_id AND A.location_id = C.location_id AND A.isdelete=0 ".$where; $result = mysql_query($sql) or die($sql . '<br />' . mysql_error()); 1. the parenthesis should be removed from the actual SQL. 2. run that snippet and post the results. Link to comment https://forums.phpfreaks.com/topic/260001-how-to-check-entries-exist-in-mysql-database-or-not/#findComment-1332693 Share on other sites More sharing options...
vinod_vsd Posted March 31, 2012 Author Share Posted March 31, 2012 thanks for help this issue is solve i just use if(mysql_num_rows($result)<=0) continue; after use of that i get result of only valid exist entries... Link to comment https://forums.phpfreaks.com/topic/260001-how-to-check-entries-exist-in-mysql-database-or-not/#findComment-1332955 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.