Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

how do I search two-dimiensional results set array

 
   Database Forums (Home) -> PHP RSS
Next:  Ghost update in concurrent transaction  
Author Message
NotGiven

External


Since: Jun 10, 2004
Posts: 32



(Msg. 1) Posted: Sun Aug 29, 2004 2:23 pm
Post subject: how do I search two-dimiensional results set array
Archived from groups: comp>lang>php (more info?)

Here's the pertinent code to get the SQL results. It is generated by
dreamweaver adn I'm trying to learn to code php so I don't depend on DW to
do it for me.

$query_rsSummary = "SELECT sid, Count(wid) FROM plotting GROUP BY sid";
$rsSummary = mysql_query($query_rsSummary, $tableG) or die(mysql_error());
$row_rsSummary = mysql_fetch_assoc($rsSummary);


How do I search the array to see if a certain "sid" has an entry in the
array?

Thanks!

 >> Stay informed about: how do I search two-dimiensional results set array 
Back to top
Login to vote
steve




Joined: Jan 06, 2004
Posts: 660



(Msg. 2) Posted: Sun Aug 29, 2004 3:04 pm
Post subject: Re: how do I search two-dimiensional results set array [Login to view extended thread Info.]

NotGiven wrote:
Here's the pertinent code to get the SQL results. It is generated by
dreamweaver adn I'm trying to learn to code php so I don't depend on DW to
do it for me.

$query_rsSummary = "SELECT sid, Count(wid) FROM plotting GROUP BY sid";
$rsSummary = mysql_query($query_rsSummary, $tableG) or die(mysql_error());
$row_rsSummary = mysql_fetch_assoc($rsSummary);


How do I search the array to see if a certain "sid" has an entry in the
array?

Thanks!


There is an example here for searching multi-dim arrays
http://us4.php.net/manual/en/function.array-search.php

 >> Stay informed about: how do I search two-dimiensional results set array 
Back to top
Login to vote
Samu




Joined: Aug 16, 2004
Posts: 1



(Msg. 3) Posted: Sun Aug 29, 2004 3:10 pm
Post subject: Re: how do I search two-dimiensional results set array [Login to view extended thread Info.]

If you just need to know if the data requested is present at all you could try this: http://us4.php.net/manual/en/function.in-array.php

t samu
 >> Stay informed about: how do I search two-dimiensional results set array 
Back to top
Login to vote
Tim Van Wassenhove

External


Since: May 08, 2004
Posts: 134



(Msg. 4) Posted: Sun Aug 29, 2004 4:22 pm
Post subject: Re: how do I search two-dimiensional results set array [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article , NotGiven wrote:
 > Here's the pertinent code to get the SQL results. It is generated by
 > dreamweaver adn I'm trying to learn to code php so I don't depend on DW to
 > do it for me.
 >
 > $query_rsSummary = "SELECT sid, Count(wid) FROM plotting GROUP BY sid";
 > $rsSummary = mysql_query($query_rsSummary, $tableG) or die(mysql_error());
 > $row_rsSummary = mysql_fetch_assoc($rsSummary);
 >
 >
 > How do I search the array to see if a certain "sid" has an entry in the
 > array?

Why would you do the searching if you can let MySQL do the searching for
you?

Get yourself a book on databases (sql) and read all you can on the WHERE
clause Wink

--
Tim Van Wassenhove <http://home.mysth.be/~timvw>
 >> Stay informed about: how do I search two-dimiensional results set array 
Back to top
Login to vote
NotGiven

External


Since: Jun 10, 2004
Posts: 32



(Msg. 5) Posted: Sun Aug 29, 2004 6:22 pm
Post subject: Re: how do I search two-dimiensional results set array [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

This is not really a SQL problem. I need the fuill result set. I just
needed to figure out how to loop through the result set in the php code to
display results for each main ID. I'll post the solution a little later.


"Tim Van Wassenhove" wrote in message


  > > Here's the pertinent code to get the SQL results. It is generated by
  > > dreamweaver adn I'm trying to learn to code php so I don't depend on DW
to
  > > do it for me.
  > >
  > > $query_rsSummary = "SELECT sid, Count(wid) FROM plotting GROUP BY sid";
  > > $rsSummary = mysql_query($query_rsSummary, $tableG) or
die(mysql_error());
  > > $row_rsSummary = mysql_fetch_assoc($rsSummary);
  > >
  > >
  > > How do I search the array to see if a certain "sid" has an entry in the
  > > array?
 >
 > Why would you do the searching if you can let MySQL do the searching for
 > you?
 >
 > Get yourself a book on databases (sql) and read all you can on the WHERE
 > clause Wink
 >
 > --
 > Tim Van Wassenhove <http://home.mysth.be/~timvw>
 >> Stay informed about: how do I search two-dimiensional results set array 
Back to top
Login to vote
CJ Llewellyn2

External


Since: Aug 29, 2004
Posts: 27



(Msg. 6) Posted: Sun Aug 29, 2004 8:21 pm
Post subject: Re: how do I search two-dimiensional results set array [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"NotGiven" wrote in message

 > Here's the pertinent code to get the SQL results. It is generated by
 > dreamweaver adn I'm trying to learn to code php so I don't depend on DW to
 > do it for me.
 >
 > $query_rsSummary = "SELECT sid, Count(wid) FROM plotting GROUP BY sid";
 > $rsSummary = mysql_query($query_rsSummary, $tableG) or die(mysql_error());
 > $row_rsSummary = mysql_fetch_assoc($rsSummary);
 >
 >
 > How do I search the array to see if a certain "sid" has an entry in the
 > array?

You may find aliases invaluable, especially when working with group by
functions:-

$query_rsSummary = "SELECT sid, Count(wid) AS c_wid FROM plotting GROUP BY
sid";
$rsSummary = mysql_query($query_rsSummary, $tableG) or die(mysql_error());

<a rel="nofollow" style='text-decoration: none;' href="http://www.php.net/manual/en/function.mysql-fetch-assoc.php" target="_blank">http://www.php.net/manual/en/function.mysql-fetch-assoc.php</a>

while($row = mysql_fetch_assoc($rsSummary))
{
if($row['sid'] == 'whatever')
{
printf("SID %s occurs %s times in this data",
$row['sid'],
$row['c_wid']);
}
}
 >> Stay informed about: how do I search two-dimiensional results set array 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Caching MySQL Search Query & Results - I'm developing a site that may eventually have a very large database of users (hopefully, but who knows). It will be a community website where users can search each other (think Friendster, Classmates, every dating site out there, etc.). Often there...

accessing array data inside of an array - I want to extract the name of the photo uploaded. print_r of $_FILES yields: Files: Array ( [picture] => Array ( [name] => DSC_1802-saoirse-riona.jpg [type] => image/jpeg [tmp_name] => /tmp/phpJTspHZ [error] => 0 [size] => 76096 ) ) ...

Array - Hi Can you help me sort my array on salary $Person[$personid][salary] e.g. $Person[1][20000] $Person[2][5000] $Person[3][15000] $Person[4][10000] to $Person[2][5000] $Person[4][10000] $Person[3][15000] $Person[1][20000] Thanx

SUM of array - I want to get the sum of the array key values. ex: $key1=>10, $key2=>15, $key3=>5 I want variable $sum = 30. any solution?

array() VS Array() - which one is recommend? seems they perform the same thing... regards, howa
   Database Forums (Home) -> PHP All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]