Yeah, its fine, as long as your while loop ends
just after a quick glance, it looks like an infinite loop,
you might try
instead of
while (count($aListItems)){
try
while (isset($aListItems[$i])){
or
while ($i < count($aListItems)){
--
Luke
"Jon Bennett" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Ahh, i was originally thinking of having a examples table, but when
> writing the post I decided it might not be nessecary :-)
>
> ok, that bit I understand fine, it's getting the data into the DB first
> that's bugging me, would something like this be ok ?
>
> function addNews($aArgs, $aListItems, $aTableItems) {
>
> // create example record
> $sql = "INSERT INTO _training_examples (
> training_id,
> status,
> created_dt,
> modified_dt
> ) values (
> ".$this->$_iTrainingId.",
> 1,
> NOW(),
> NOW()
> )";
>
> if (DB::isError($rsTmp = $this->_oConn->query($sql))) {
>
> catchExc($rsTmp->getMessage());
> return false;
>
> } else {
>
> / Use MySQL's LAST_INSERT_ID() method to query for the
> insert id
> $sql = "SELECT LAST_INSERT_ID()";
>
> // Check for DB class exceptions
> if (DB::isError($iExampleId = $this->_oConn->getOne($sql)))
> {
>
> // Report exceptions if present
> catchExc($iExampleId->getMessage());
>
> // Unset the product id
> unset($iExampleId);
> }
>
> $i = 0;
>
> while (count($aListItems)){
> // add multiple records to db for list_items
> $sql = "INSERT INTO _training_list_items (
> training_id,
> example_id,
> listitem,
> status,
> created_dt,
> modified_dt
> ) values (
> ".$this->$_iTrainingId.",
> ".$iExampleId.",
> ".$aListItems[$i]['List Item Text'].",
> 1,
> NOW(),
> NOW()
> )";
> $i++
>
> }
>
> And then repeat the 2 while loop for the table_items table.
>
> Is it ok to have INSERT statements enclosed in a while loop ???
>
> Cheers,
>
> Jon
>
>
> jon bennett | [EMAIL PROTECTED]
> new media creative
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> J b e n . n e t
>
> 91 Gloucester Rd, Trowbridge, Wilts, BA14 0AD
> t: +44 (0) 1225 341039 w: http://www.jben.net/
>
>
> On 15 Jan 2004, at 18:45, Richard Davey wrote:
>
> > Hello Jon,
> >
> > Thursday, January 15, 2004, 6:23:51 PM, you wrote:
> >
> > JB> The way I was thinking of doing this was to have 3 tables:
> >
> > JB> training_subsections
> > JB> training_list_items
> > JB> training_table_items
> >
> > JB> My problem is, is it a 'reccomended' way of doing things to query
> > the
> > JB> db multiple times for each new list_item and table_item in one go
> > ??? I
> >
> > There is no reason why you can't, but I'm quite convinced that with a
> > little more fore-thought you could come up with a table structure that
> > meant you didn't have to do this.
> >
> > For example (if I've understood your post correctly) why not have a
> > training_examples table and then use an ExampleID for the subsections,
> > list items and table items.
> >
> > That way you know which example you're dealing with and can bring back
> > all of the sub sections accordingly, linking in the list and table
> > items.
> >
> > If this isn't possible, post a few more details about what you want to
> > achieve and perhaps your table schema.
> >
> > --
> > Best regards,
> > Richard mailto:[EMAIL PROTECTED]
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php