Jump to content
php.lv forumi

mysql query -> array.


thesnarkie

Recommended Posts

$code_result = mysql_query("SELECT `code` FROM `item` WHERE `category_id`='185'",$db);
$result_b = mysql_fetch_array($code_result);
if(in_array($searchstring,$result_b)) {
  $searchstring = 0;
}

Ko es nepareizi izdarīju, ka man print_r($result_b); arrajā parādās tikai kverija pirmais row?

Edited by thesnarkie
Link to comment
Share on other sites

Tu aizmirsi par to, ka vajadzīgs jāciklē caur ierakstiem..

 

Bet vispār jau pamatos pieeja nav pareiza. Tev nav jāvelk no datubāzes ārā visi ieraksti un php pusē jāsalīdzina, to var izdarīt mysql pusē.

SELECT COUNT(*) FROM `item` WHERE `category_id`='185' AND `lauks`='$searchstring'

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...