But what do all those $row['fieldname'} rows do? Call me ignorant
(you wouldn't be the first), but a statement that simply has a
variable name doesn't DO anything. Should these have echos in front
of them?
--- Adam Voigt <[EMAIL PROTECTED]> wrote:
> Umm, he is putting them into an array, I quote:
>
> while ($row = mysql_fetch_array($result)) {
> > > $row['Books.Title'];
> > > $row['Books.Author'];
> > > $row['Books.ISBN'];
> > > $row['BookList.dbase'];
> > > $row['BookList.dbase_user'];
> > > $row['BoxSet.BoxSet'];
> > > $row['Category.Category'];
> > > $row['Category.Sub_category'];
> > > $row['Publisher.Publisher'];
> > > $row['AuthUsers.email'];
> > >
> > > }
>
> See the while condition?
>
> On Wed, 2002-11-27 at 06:03, Chris Barnes wrote:
> > You need to put your $result into an array. you can use:
> >
> > $result_array = mysql_fetch_array($result);
> >
> > then, if you know the field names in the array, print them like
> so:
> >
> > echo $result_array["field1"];
> > echo $result_array["field2"];
> >
> > or if you dont know their names you can refer to their position
> numbers
> > starting from 0 e.g.
> >
> > echo $result_array[0];
> > echo $result_array[1];
> >
> > using the position numbers you could put together a quick script
> to
> > crawl through the array and print all the fields with a few lines
> of
> > code.
> >
> > On Wed, 2002-11-27 at 05:09, The Cossins Fam wrote:
> > > Hello.
> > >
> > > I am using MySQL as a database for a departmental library. I
> have written
> > > a quick search script, but keep getting "resource id #2" as a
> result to my
> > > search. I have read the online documentation for the
> > > mysql_fetch_array() function and must say, I don't see that I'm
> missing
> > > anything. However, I've only started programming, much less
> working with
> > > PHP, so perhaps someone can help me out. Here's my code:
> > >
> > > <?
> > >
> > > $quickSearch = "mcse";
> > >
> > > $table1 = "Books";
> > > $table2 = "BookList";
> > > $table3 = "BoxSet";
> > > $table4 = "Category";
> > > $table5 = "Publisher";
> > > $table6 = "AuthUsers";
> > > $table7 = "CD";
> > >
> > > $connection = mysql_connect("localhost", "root") or
> die("Couldn't connect
> > > to the library database.");
> > >
> > > $db_select = mysql_select_db("library", $connection) or
> die("Couldn't
> > > select the library database.");
> > >
> > > $search = "SELECT * FROM $table1 LEFT JOIN $table2 ON
> Books.BookListID =
> > > BookList.BookListID
> > > LEFT JOIN $table3 ON Books.BoxSetID = BoxSet.BoxSetID
> > > LEFT JOIN $table4 ON Books.CategoryID =
> Category.CategoryID
> > > LEFT JOIN $table5 ON Books.PublisherID =
> Publisher.PublisherID
> > > LEFT JOIN $table6 ON Books.auID = AuthUsers.auID
> > > LEFT JOIN $table7 ON Books.CD = CD.CD_ID
> > > WHERE Books.Title LIKE \"%'$quickSearch'%\"
> > > OR Books.Author LIKE \"%'$quickSearch'%\"
> > > OR Books.ISBN LIKE \"%'$quickSearch'%\"
> > > OR BookList.dbase LIKE \"%'$quickSearch'%\"
> > > OR BookList.dbase_user LIKE \"%'$quickSearch'%\"
> > > OR BoxSet.BoxSet LIKE \"%'$quickSearch'%\"
> > > OR Category.Category LIKE \"%'$quickSearch'%\"
> > > OR Category.Sub_category LIKE \"%'$quickSearch'%\"
> > > OR Publisher.Publisher LIKE \"%'$quickSearch'%\"";
> > >
> > > $result = mysql_query($search, $connection) or die("Couldn't
> search the
> > > library.");
> > >
> > > while ($row = mysql_fetch_array($result)) {
> > > $row['Books.Title'];
> > > $row['Books.Author'];
> > > $row['Books.ISBN'];
> > > $row['BookList.dbase'];
> > > $row['BookList.dbase_user'];
> > > $row['BoxSet.BoxSet'];
> > > $row['Category.Category'];
> > > $row['Category.Sub_category'];
> > > $row['Publisher.Publisher'];
> > > $row['AuthUsers.email'];
> > >
> > > }
> > >
> > >
> > > ?>
> > >
> > > I then have some HTML to display the result of the search. I
> don't
> > > receive any error messages - I just see an empty table from the
> HTML
> > > code I wrote. I added an echo of the $result to find the
> "resouce id
> > > #2".
> > >
> > > Thanks for any help you can provide.
> > >
> > > --joel
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> _________________________________________________________________
> > > The new MSN 8: advanced junk mail protection and 2 months FREE*
>
> > > http://join.msn.com/?page=features/junkmail
> > >
> > >
> > > --
> > > PHP Database Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> --
> Adam Voigt ([EMAIL PROTECTED])
> The Cryptocomm Group
> My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc
>
> ATTACHMENT part 2 application/pgp-signature name=signature.asc
=====
Mark Weinstock
[EMAIL PROTECTED]
***************************************
You can't demand something as a "right" unless you are willing to fight to death to
defend everyone else's right to the same thing.
-Stolen from the now-defunct Randy's Random mailing list.
***************************************
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php