mysql query

  • foodstyling
  • Novice
  • Novice
  • foodstyling
  • Posts: 16
  • Loc: Antwerp

Post 3+ Months Ago

I found a piece of code that I don't understand (the $query part after like):

$numresults = mysql_query("SELECT * FROM your_table WHERE name LIKE '% ". $query . "%' ");

In fact, I would like to use the elements of that query and replace them with my own elements. My query:

$numresults = mysql_query ("SELECT recept AS RECEPTEN FROM recepten WHERE ingredienten LIKE '%$param1%' and catID =('$catID');

foodstyling
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

You are close. The % signs are actually used for tolkiens/wildcards where mysql will return all that have $query included in them, your's is almost correct but the % have to be in quotes like:
Code: [ Select ]
$numresults = mysql_query ("SELECT recept AS RECEPTEN FROM recepten WHERE ingredienten LIKE '%" . $param1 . "%' and catID =('$catID');
  • foodstyling
  • Novice
  • Novice
  • foodstyling
  • Posts: 16
  • Loc: Antwerp

Post 3+ Months Ago

Thanks,
I thought the query was the problem for my next/previous problem, but it doesn't seem to be so. Can I ask you to check out the code on my next/previous post, because it start to drive me crazy.

Thanks in advance,

foodstyling

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: Liamw411 and 69 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.