Jump to content

Search by Cook time


dropfaith

Recommended Posts

http://lawrenceguide.org/recipes/profile.php?Name=Salt%20and%20Vinegar%20Chicken

 

so im building a basic recipes feature for my site and was wondering i want to make a quick meals link and have it only pull out the data with a readyin time of less then say 30 minutes

 

i have no idea where to start i know selects and things like that HERES basic code just not sure what to use for the where statement to get things with a value less then something

<?php
// includes
include("../template/conf.php");


// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");

// select database
mysql_select_db($db) or die ("Unable to select database!");

// generate and execute query
	if(!is_array($_GET['Type']))
{
	$Medium = mysql_escape_string($_GET['Type']);
				$query = "SELECT * FROM Recipes  WHERE Readyin = 'LESS THEN 30mINS' order by Name";

	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
}
else
{
//special circumstance
	$query = "SELECT * FROM Recipes";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
}

// if records present
if (mysql_num_rows($result) > 0)
{
// iterate through resultset
// print article titles
while($row = mysql_fetch_object($result))
{
?>

Link to comment
https://forums.phpfreaks.com/topic/129739-search-by-cook-time/
Share on other sites

its currently in varchar and is form submitted by users  i can limit users to doing it in minutes without an issue really

 

right now its just a text field that allows them to type in anything

 

thanks  ill play with that in a second should i change the field from varchar or is that okay

Link to comment
https://forums.phpfreaks.com/topic/129739-search-by-cook-time/#findComment-672651
Share on other sites

I would recommend making the column integer only and limiting users to submitting the time in minutes only. Other than that you'll have a db with cooking times in minutes, hours and every conceivable format in between which will make it virtually impossible to search...

Link to comment
https://forums.phpfreaks.com/topic/129739-search-by-cook-time/#findComment-672652
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.