Sub-Sub-strings?

Getting and posting many sql results

Page 1 of 1

1 Replies - 1552 Views - Last Post: 24 June 2006 - 11:29 PM Rate Topic: -----

#1 max302  Icon User is offline

  • Proud supporter of the lulz
  • member icon

Reputation: 2
  • View blog
  • Posts: 1,281
  • Joined: 05-March 06

Sub-Sub-strings?

Posted 14 June 2006 - 04:47 PM

Still in relation with the visitor counter thingy, but this time it's to display the information. What I want to do is run a query for all logged ips and display in a table but I do not know how to manipulate such amounts of information. So far here is my code.
	$ygetrecord = "SELECT * FROM visitcount ORDER BY lastvisit";
	$ygetrecordq = mysql_query($ygetrecord);
	$ygetrecordlen = mysql_num_rows($ygetrecordq);
	$ygetrecordr = mysql_fetch_array($ygetrecordq);
	$ycounter = 0;
	while ($ycounter >= 20)
		{
		}
	
	}



I should have echoed the table tag with title fields and all but I'll do that later. In the while loop, which I think I'll convert to a for, will shoot out all the info. In my head this would wokr in sub sub-strings like: $ygetrecordr['$ycounter'][$visitcount]. This, according to me would echo the visitcount information of the of the result number whatever ycounter is on. Am I right? what is the proper technique to adopt in order to return lost of info catalogue style?

Is This A Good Question/Topic? 0
  • +

Replies To: Sub-Sub-strings?

#2 cyberscribe  Icon User is offline

  • humble.genius
  • member icon

Reputation: 10
  • View blog
  • Posts: 1,062
  • Joined: 05-May 02

Re: Sub-Sub-strings?

Posted 24 June 2006 - 11:29 PM

View Postmax302, on 14 Jun, 2006 - 03:39 PM, said:

	$ycounter = 0;
	while ($ycounter >= 20)
		{
		}


Thaty "while" loop is never going to execute. But I digress.

Are you trying to display the number of records that have the same field? Is this field the IP address? If so, you can use the MySQL count() select function and GROUP BY clause to return this data directly from MySQL:
Select count(*) as myCount, ip, lastvisit from visitcount group by ip order by lastvisit DESC


This query will give you back three columns: myCount, ip, and visitcount. myCount is the number of logins for the ip, ip is the ip, and lastvisit is the most recent visit on record for that ip. Is that what you want?

Collecting the data into an array (or a multidimensional array, which when access is called a sub-array -- not a sub-string) is also an option if you can't do what you want to do directly in MySQL. But MySQL is generally faster than doing post-processing in PHP.

Hope that helps.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1