note 101065 added to language.types.array
| From: | thesurge0n at osu1 dot php dot net | Date: | Wed, 24 Nov 2010 04:35:14 +0000 |
| Subject: | note 101065 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174309@lists.php.net to get a copy of this message | ||
BEFORE ANYONE EVEN COMMENTS ON MY PROGRAMMING, IT WORKS THEREFORE IT'S FINE.
AND ITS AND EXAMPLE :)
<?php
/*
*Description: Displays top 3 positions...
*/
/*include password file*/
include("./Adverts.php");
/*connect to database*/
$cxn = mysql_connect($host, $user, $passwd)
or die ("Couldn't connect to server.");
/*select database*/
mysql_select_db($dbname);
/*set the query to make*/
$query = "SELECT * FROM
Favourites WHERE Favourites.loginName =
'ANAME'";
/*perform query or error*/
$result = mysql_query($query)
or die ("Couldn't execute query.");
/*add values to $row array*/
while ($row = mysql_fetch_assoc($result))
{
/*removes username from array*/
unset($row['loginName']);
/*sort array in reverse order*/
arsort($row);
/*set $c variable for counting and set to zero*/
$c=0;
/*foreachloop to set Key/Value pair*/
foreach($row as $k => $v)
{
/*add 1 to $c so index is always different*/
$c=$c+1;
/*create a 3 dimensional temp array to store index, Key and Value*/
$tmp = array(
array($k, array($v))
);
/*echo each index, key and value to screen*/
echo "$tmp[$c]['$k']['$v']<br/>";
/*set a condition to break out of loop after showing 3 results*/
if($c == "3")
{
break;
}
}
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 81.98.228.172
----
Manual Page -- http://www.php.net/manual/en/language.types.array.php
Edit -- https://master.php.net/note/edit/101065
Del: integrated -- https://master.php.net/note/delete/101065/integrated
Del: useless -- https://master.php.net/note/delete/101065/useless
Del: bad code -- https://master.php.net/note/delete/101065/bad+code
Del: spam -- https://master.php.net/note/delete/101065/spam
Del: non-english -- https://master.php.net/note/delete/101065/non-english
Del: in docs -- https://master.php.net/note/delete/101065/in+docs
Del: other reasons-- https://master.php.net/note/delete/101065
Reject -- https://master.php.net/note/reject/101065
Search -- https://master.php.net/manage/user-notes.php