Just wanted to say THANK YOU!
Really helped me understand.
Just went back to refresh on print/sprintf() and it the ease of
understanding skyrocketed.
Came to realize that:
****************************************************************
PAGE 272-273
$tableName = "addressbook";
$stmt = "CREATE TABLE %s(NAME VARCHAR(255), EMAIL VARCHAR(255), CITY
VARCHAR(255), DESCRIPTION VARCHAR(255), TELEPHONE VARCHAR(255), ROWID INT
PRIMARY KEY AUTO_INCREMENT)";
****************************************************************
I could just as easily replace the "%s" with the variable "$tableName"
and the output would be the same.
This was what to the longest to crack down on....the
"$stmt" variable isn't called until later in the app(thnx Jeremy), and
that is with the sprintf() function, which in turn relates to the "%s"
This line of code:
***************************************************************
PAGE 274
printf("<BR> Created Table %s.%s <P>", $databaseName, $tableName);
***************************************************************
Also reminded me that all examples aren't meant to be optimized for
functionality or ease, but to show you what COULD be done.
(Even if you'd never use it)
Even though I'd almost never use the above line of code exactly as
written, I'm glad it WAS used, and happy people are here to help each
other understand why.
Made me have to refresh on the previous chapters, and I LOVE that!
Thank you to EVERYONE who replied, and since you helped me understand what
was going on, I'm sure you already understand what I've wrote.
I basically threw it in for future newbies like myself who may come across
this situation.
Later all,
codemecode
> Hello,
>
> regarding your questions,
>
> > I don't understand what will be created by using "%s" as the table name.
>
> They're using a function for formatting strings called sprintf(). Take a
> look for example at the query on page 274 within the if statement. The way
> to use sprintf and printf is explained on pages 185 to 187 of the book. The
> %s is nothing to do with SQL.
>
> > Line (7) Above. I don't understand what "PRIMARY KEY AUTO_INCREMENT"
> > is supposed to do.
>
> This does indeed create an auto incrementing key called 'rowid' for each row
> in the table.
>
> Hope this helps
> Grant