I have two table.based on service i need to fetch record from two dates. i.e Tips and category.
category table has column id, name.
Tips table hving id,servicename,services,Date.
service is foreign key of category table. and there is entry in database in -2-, format. I want query for this format. -2-, means 2 is servicename i.e. -HNI-,
Please find my query. do the needful.
Expand|Select|Wrap|Line Numbers
- <?php
- error_reporting(0);
- $conn=mysql_connect("localhost","root","");
- if(!isset($conn)){
- die("connnection failed");
- }
- mysql_select_db("pinnacle");
- $fdate= $_GET['fdate'];
- $tdate= $_GET['todate'];
- $s1= $_GET['service'];
- echo $q="SELECT c1.id, t1.servicename,t1.sentbyname,t1.date,t1.time FROM category AS c1 INNER JOIN tips AS t1 ON c1.id = t1.services WHERE t1.date BETWEEN '$fdate' and '$tdate' order by t1.date asc";die;
- $rs=mysql_query($q);
- when i am removing -HNI-, this symbol from database query works fine.
- is there any way to hard code
- like
- echo $q="SELECT c1.id, c1.name,t1.sentbyname,t1.date,t1.time FROM category AS c1 INNER JOIN tips AS t1 ON "-".c1.id."-," = "-".t1.services."-," WHERE t1.date BETWEEN '$fdate' and '$tdate' order by t1.date asc";die;