2007. 02. 20, kedd keltezéssel 08.28-kor Jim Lucas ezt írta:
> Németh Zoltán wrote:
> > 2007. 02. 20, kedd keltezéssel 08.17-kor Jim Lucas ezt írta:
> >> Mike Shanley wrote:
> >>> I'd like to think I understood code a little better than this, but I've 
> >>> got a problem with my WHERE...
> >>>
> >>> I know it's the WHERE because I get a good result when I leave it out. 
> >>> And the random function is also working... I honestly can't figure it 
> >>> out. Thanks in advance for help with this laughable prob.
> >>> ---------------------------
> >>> // How many are there?
> >>>
> >>> $result = mysql_query("SELECT count(*) FROM fortunes");
> >>> $max = mysql_result($result, 0);
> >>>
> >>> // Get randomized!... the moderated way...
> >>>
> >>> $randi = mt_rand(1, $max-1);
> >>> $q = "SELECT text FROM fortunes WHERE index = '$randi'";
> >>> $choose = mysql_query($q);
> >>> $chosen1 = mysql_fetch_array($choose);
> >> ARRAY???
> > 
> > what's wrong with that?
> > http://hu.php.net/manual/en/function.mysql-fetch-array.php
> > 
> > and then you can of course refer to it with indexes, both numeric and
> > associative
> > I don't see anything problematic with that...
> > 
> > greets
> > Zoltán Németh
> > 
> >>> // Ready to ship...
> >>>
> >> Referring to it via an index...  could be the problem
> >>> $fortune = '<span class="quotecyc">&quot;' . $chosen1[0] . 
> >>> '&quot;<br/>-Omniversalism.com</span>';
> >>>
> >>> mysql_close();
> >>>
> >>
> >> -- 
> >> Enjoy,
> >>
> >> Jim Lucas
> >>
> >> Different eyes see different things. Different hearts beat on different 
> >> strings. But there are times for you and me when all such things agree.
> >>
> >> - Rush
> >>
> > 
> I would suggest using either assoc or row this way there is no 
> confusion.  Plus it doesn't take as much resources. :)

ok, it's probably better to decide which to use in advance and then
stick to that one... it's always better to plan carefully before coding,
and use the optimal tools needed for the job.
however, I think sometimes everyone starts coding without detailed
plans ;)

greets
Zoltán Németh

> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to