Ask a Question related to PHP Development, Design and Development.
-
David Nicholson #1
Re: [PHP] Is there an easier way?
Hello,
This is a reply to an e-mail that you wrote on Fri, 1 Aug 2003 at
02:04, lines prefixed by '>' were originally written by you.statement> Hi,
> This is what i am doing, querying a database via a selectAnd> (getting
> max 5 records), then dumping everything into an associative array.array> then
> assign the arrays value to a variable for easier readibility and
> usability
> like so:
> if(!($rs = mysql_query($q))) // querying
> { echo "Query failed". mysql_error(); exit; }
> $n = 0;
> while ($line = mysql_fetch_assoc($rs)) { //dumping into anThe logic you are using is a bit messed up. You should be aiming to> foreach ($line as $field => $value) {
> $data[$field][$n] = $value;
> }
> $n++;
> }
> and this is how i use the arrays values (blah is the field name):
> $blah1=$data['blah'][0];
> $blah2=$data['blah'][1];
> $blah3=$data['blah'][2];
get an array like...
$data[0]['field1']
['field2']
[1]['field1']
['field2']
...and this can be done like this...
$data = array();
while ($line = mysql_fetch_assoc($rs)) {
$data[] = $line;
}
HTH
David.
--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: [url]http://www.phpmachine.com/[/url]
Professional Web Development by David Nicholson
[url]http://www.djnicholson.com/[/url]
QuizSender.com - How well do your friends actually know you?
[url]http://www.quizsender.com/[/url]
(developed entirely in PHP)
David Nicholson Guest
-
Easier way then to use a join here?
I use the following select statement that correctly retrieves the data I want: SELECT * FROM userpref AS pref JOIN userpref AS pref2 ON... -
[PHP] easier than switch
skate wrote: If you're really sure only one will be sent: $type = $_POST . $_POST . $_POST . $_POST . $_POST; will achieve what you're... -
easier than switch
On Mon, Aug 04, 2003 at 11:19:42PM +0100, skate wrote: You have a single page, containing multiple forms, all of which share the same action? ... -
Is there an easier way?
Hi, This is what i am doing, querying a database via a select statement (getting max 5 records), then dumping everything into an associative array.... -
Tell me how it was easier???
Your steps: 1. Draw 5 filled squares. 2. Group the squares. 3. Double click the contents to change the color of the fills. 4. Duplicate the group...



Reply With Quote

