jcadima
3/10/2016 - 9:40 PM

Mysql 'LIKE' Search

Mysql 'LIKE' Search


<?php
/*
This will retrieve a result if any of firstname lastname or email match in the database

*/


		$sql = "SELECT orders.order_id, first_name, last_name, ticket_name, ticket_price, 
					   orders.fees, orders.amount, order_tickets.boxname, orders.email 
					   
				FROM event,orders,order_tickets,ticket 
				WHERE order_tickets.ticket_id=ticket.ticket_id 
				AND orders.event_id=event.id 
				AND order_tickets.order_id = orders.order_id 
				AND organizer_id=".$_SESSION["organizer_id"]."
				AND  order_tickets.ticket_id=ticket.ticket_id  
				AND ( first_name LIKE '%{$_GET["key"]}%'  OR  last_name LIKE '%{$_GET["key"]}%' OR  email LIKE '%{$_GET["key"]}%'   )
				AND event.id=".$_GET["id"];
				
// HARDCODED:
SELECT orders.order_id, first_name, last_name, ticket_name, ticket_price, orders.fees, orders.amount, order_tickets.boxname, orders.email
FROM event, orders, order_tickets, ticket
WHERE order_tickets.ticket_id = ticket.ticket_id
AND orders.event_id = event.id
AND order_tickets.order_id = orders.order_id
AND organizer_id =38
AND ( first_name LIKE  '%Toto%' OR last_name LIKE  '%Walker%' OR email LIKE  '%asfdi@ijdso.com%' )
AND event.id =613