Yes, mysql_query doesn't return a list, it returns a resource
identifier. You have to create the list yourself using a loop and
mysql_fetch_object or mysql_fetch_array or one of the other "fetchers".
Before we go much further, I need to remind you that this is not a PHP
list, and that those things do exist -- that's got to be one of the
best* explained languages on earth.
The example I posted was working code ripped out of a busy site.
However it relies on the MyActiveRecord ORM to do anything.
define('MYACTIVERECORD_CONNECTION_STR', 'mysql://user:p...@localhost/
databasename');
require_once('MyActiveRecord.0.5.php');
class widgets extends MyActiveRecord{}
$list = MyActiveRecord::FindAll('widgets',null,'position ASC');
foreach($list as $item){
//print_r($item);
//do what you want with $item->name, $item->description...
}
That is all there is to that. Anything else, I really recommend this
book: ISBN:0-672-31784-2 (may be -3 now, don't know what the current
version is). PHP and MySQL Web Development, by Luke Welling and Laura
Thomson. (SAMS)
Walter
*Where by "best" I simply mean "most".
On Jun 13, 2009, at 9:04 AM, WLQ wrote:
>
> I've followed your link and tried to build the list as you suggested
> there. But it gives me.
>
> "ERRNO: 2 TEXT: Invalid argument supplied for foreach() LOCATION: ...,
> line 7"
> http://jsbin.com/elocu/edit
>
>
>> Here's a list of problems. (I use database to drive the second
>> sortable too).
>> Now, if you drag an item from originals to clones any item but not
>> the
>> first, it will be cloned and "reverted". But you wont be able to move
>> it (inside of cloned sortable), when you drag and drop one more item,
>> that item wont move ass well, but previous dropped item apparently
>> receives the ability of being dragged. What is extremely weir. Here's
>> one more weirdness, if you drag items from originals in order they
>> appear, then they will be cloned but won't be "reverted". I've also
>> added your print_r($_POST) to the update_order.php but it's giving
>> some unfair results.
>> I've uploaded the whole pack to a "some" website. Check it
>> outhttp://scriptaculous.host22.com/
>>
>> On Jun 8, 1:00 pm, Walter Lee Davis <[email protected]> wrote:
>>
>>> Gaaaaaa! I always get this backward. As Mr. Wonka would say, "Strike
>>> that; reverse it!"
>>
>>> whatever_your_list_ID_is = Array(
>>> 12 => 0,
>>> 13 => 1,
>>> 24 => 2,
>>> 2 => 3,
>>> 42 => 4
>>> )
>>
>>> Walter
>>
>>> On Jun 8, 2009, at 6:56 AM, Walter Lee Davis wrote:
>>
>>>> The data generated by Sortable.serialize looks like this after PHP
>>>> grabs it from the POST:
>>
>>>> whatever_your_list_ID_is = Array(
>>>> 0 => 12,
>>>> 1 => 13,
>>>> 2 => 24,
>>>> 3 => 2,
>>>> 4 => 42
>>>> )
>>
>>>> The keys of the array give the position, the values give the
>>>> numerical
>>>> part of the list item ID. So in this case, the list looked like
>>>> this
>>>> in the DOM when serialize() wrapped it up:
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---