Re: [PHP-DB] Search tutroial

2002-04-24 Thread Dan Swensen

Getting a search function running perplexed me, too, until I looked at the 
MySQL docs. With the Full-Text Search function I got a search function 
working in minutes. 

http://www.mysql.com/doc/F/u/Fulltext_Search.html

Watch out for the weird bug that ignores duplicate rows, though. It can make 
for zero returns in small databases for no logical reason. That drove me nuts 
until I figured out why it was happening. (It's mentioned at the bottom of 
the docs.) 


> Hi all,
> 
> Would someone kindly point me to a tutorial on designing a search 
> script for mysql db. I have tried to build one but can't get 
> anywhere with it.
> 
> Thanks
> Jennifer
> 
> --
> The sleeper has awaken
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php




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




[PHP-DB] auto-increment question

2002-04-23 Thread Dan Swensen

Hi all,

I'm wondering if there is a way to start an auto-increment field at a number 
other than 1. I'm working on a table meant to store large amounts of users, 
each with their own unique ID, but my employer wants the UIDs to be a four-
digit number, rather than starting at 1 -- but they still need to auto-
increment. Can this be done, or do I need to find a workaround (and if so, 
can anyone suggest anything?)

Thanks in advance,

Dan

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




Re: [PHP-DB] HTML tables in PHP

2002-04-10 Thread Dan Swensen

The way I do this is a very simple bit of code:

Outside the "while" statement, add the line:

$column = 1;  

Then, inside the "while" statement, take the  statements out and 
instead do something like this:

 $column++;  
   
 if ($column > 3)  
 {  
  echo "";  
  $column = 1;  
 }  

This will render a new table row every time the counter reaches 3. You can 
change that number to make as many cells as you want before rendering a new 
table row.

You will probably want to take the  out of the "while" 
statement too, unless you really do want to make a new table for every record 
returned.

Hope that helps.

Good luck,
Dan

> Hi everyone!
> 
> Is there a good tutorial on how to write html tables in PHP?
> 
> In my last post "Not displaying all records" I have the items 
> displayig all the contents of the table but they are in descending order.
> like this
> item 1
> item 2
> 
> Here is the code I am using
> 
> $query = "SELECT id, name, image, quantity FROM {$config["prefix"]}_my_items
> WHERE uid={$session["uid"]} ORDER BY id";
> $ret = mysql_query($query);
> while($row = mysql_fetch_array($ret)){
> $image = $row['image'];
> $name = $row['name'];
> $quantity = $row['quantity'];
> 
> $display_block ="$name$quantity";
> echo "$display_block";
> echo"";
> }
> 
> I have already tried this
> 
> $display_block ="$name$quantity";
> echo
> "$display_block$display_block";
> echo"";
> 
> But it displays 2 sets of all items still in descending order beside 
> each other:
> 
> item 1 item 1
> item 2 item 2
> 
> What I wnat is to display them
> 
> item 1 item 2 item 3
> 
> Is there a way to do this?
> 
> Thanks
> Jennifer
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.344 / Virus Database: 191 - Release Date: 4/2/2002
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End of Forwarded Message ---




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




[PHP-DB] Selecting random record from a database?

2002-04-02 Thread Dan Swensen

Hi all,

Does anyone know a quick and easy way to select a random record from a
database? I'm looking to put together a simple random quote generator, a la
linux's "fortune."

Any help would be much appreciated.


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




Re: [PHP-DB] Flipping through database records

2002-02-12 Thread Dan Swensen

Actually, now that I think of it... how would you move from one record to
the next, if not querying by userid?

Optimally, I would like to have a page that displays one row from a table,
and links that will allow a user to go to the next or previous row via
hyperlink. At first glance I can't think how you would do that querying by,
say, lname or the like.

- Original Message -
From: "Todd WIlliamsen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 12, 2002 10:09 PM
Subject: Re: [PHP-DB] Flipping through database records


> how about just not do it by userid?  query some other column thats in
there
>
> maybe by last name?
>
> SELECT * FROM $tablename WHERE lname = $lname LIMIT [#results per page]
>
> That should eliminate gaps
> "Olinux" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Interesting Jason, just to make sure I'm clear:
> >
> > basically, you would query the table and
> > while loop through the query result and create an
> > array and then store that in a session?
> >
> > olinux
> >
> >
> > --- Jason Cox <[EMAIL PROTECTED]> wrote:
> > > Dan,
> > >
> > > Here's an idea for you:
> > >
> > > Rather than try to pass the uid through the pages,
> > > pass a counter that will
> > > act as an index to your result array.  For example,
> > > let's say you have a
> > > query like: select * from myTable order by someCol;
> > > The order by will help
> > > give some sort of uniformity to the list on each
> > > page.  Each time you access
> > > the page, you would run this query and stuff
> > > everything into an array.  The
> > > index would be passed in and indicate which record
> > > in the array to display.
> > > You would know whether to display the 'prev' and
> > > 'next' labels by comparing
> > > the index to the size of the array.
> > >
> > > If your table is large than you can optimize your
> > > query so you're not
> > > returning all the rows everytime.  If the index was
> > > $idx then you could do
> > > something like: select * from myTable order by
> > > someCol limit $idx;  So if
> > > you had a hundred records and your index was 10 then
> > > you would only get the
> > > first 10 records.  Since we're including the order
> > > by clause, the 10 should
> > > pretty much stay the same if the table doesn't
> > > change very often.  With this
> > > technique you would need to do a count() to find out
> > > the maximum number rows
> > > in the table.  Since a count() is faster than a
> > > query returning many rows,
> > > the combination of these two statements would be a
> > > bit faster than running
> > > the original query on a large table.  But then
> > > again, on a large table I
> > > doubt someone would want to browse each row.  That's
> > > kinda like looking for
> > > a good book by browsing the card catalog at the
> > > library... :)
> > >
> > > Hope that helps,
> > > Jason Cox
> >
> > __
> > Do You Yahoo!?
> > Send FREE Valentine eCards with Yahoo! Greetings!
> > http://greetings.yahoo.com
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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




Re: [PHP-DB] Flipping through database records

2002-02-12 Thread Dan Swensen

Actually, I didn't think of that. That may work.

Thank you, Mr. Williamsen and Mr. Cox for your suggestions. I will try out
both solutions.

- Original Message -
From: "Todd WIlliamsen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 12, 2002 10:09 PM
Subject: Re: [PHP-DB] Flipping through database records


> how about just not do it by userid?  query some other column thats in
there
>
> maybe by last name?
>
> SELECT * FROM $tablename WHERE lname = $lname LIMIT [#results per page]
>
> That should eliminate gaps
> "Olinux" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Interesting Jason, just to make sure I'm clear:
> >
> > basically, you would query the table and
> > while loop through the query result and create an
> > array and then store that in a session?
> >
> > olinux
> >
> >
> > --- Jason Cox <[EMAIL PROTECTED]> wrote:
> > > Dan,
> > >
> > > Here's an idea for you:
> > >
> > > Rather than try to pass the uid through the pages,
> > > pass a counter that will
> > > act as an index to your result array.  For example,
> > > let's say you have a
> > > query like: select * from myTable order by someCol;
> > > The order by will help
> > > give some sort of uniformity to the list on each
> > > page.  Each time you access
> > > the page, you would run this query and stuff
> > > everything into an array.  The
> > > index would be passed in and indicate which record
> > > in the array to display.
> > > You would know whether to display the 'prev' and
> > > 'next' labels by comparing
> > > the index to the size of the array.
> > >
> > > If your table is large than you can optimize your
> > > query so you're not
> > > returning all the rows everytime.  If the index was
> > > $idx then you could do
> > > something like: select * from myTable order by
> > > someCol limit $idx;  So if
> > > you had a hundred records and your index was 10 then
> > > you would only get the
> > > first 10 records.  Since we're including the order
> > > by clause, the 10 should
> > > pretty much stay the same if the table doesn't
> > > change very often.  With this
> > > technique you would need to do a count() to find out
> > > the maximum number rows
> > > in the table.  Since a count() is faster than a
> > > query returning many rows,
> > > the combination of these two statements would be a
> > > bit faster than running
> > > the original query on a large table.  But then
> > > again, on a large table I
> > > doubt someone would want to browse each row.  That's
> > > kinda like looking for
> > > a good book by browsing the card catalog at the
> > > library... :)
> > >
> > > Hope that helps,
> > > Jason Cox
> >
> > __
> > Do You Yahoo!?
> > Send FREE Valentine eCards with Yahoo! Greetings!
> > http://greetings.yahoo.com
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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




[PHP-DB] Flipping through database records

2002-02-12 Thread Dan Swensen


Hello,

I am attempting to put together a page whereby results from a database are
displayed, and previous / next hyperlinks allow the user to "flip" through
records, one at a time. I attempted to do this by using a unique ID (that
auto increments)
and then including links like so at the bottom of the page:

print("[previous] ");

print("[next]");

The problem with this, is that if there are gaps in the auto_increment id
(such as records that have been deleted), the page will (of course) show up
as blank or otherwise muck up. Similarly, once the user moves past the last
record, the same fubar will occur.

I can't be the first one who has tried to do this... can anyone offer some
suggestions as to how to go about this more cleanly and efficiently?

Thanks in advance for any help.




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




[PHP-DB] Flipping through records

2002-02-12 Thread Dan Swensen

Hello,

I am attempting to put together a page whereby results from a database are
displayed, and previous / next hyperlinks allow the user to "flip" through
records. I attempted to do this by using a unique ID (that auto increments)
and then including links like so at the bottom of the page:



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