RE: [PHP-DB] RE: Search results

2002-02-06 Thread Andrew Chase

Yes, sorry about that. :P  I need to eat lunch now.

-Andy

> -Original Message-
> From: Chris Boget 
> Subject: Re: [PHP-DB] RE: Search results

> you mean:
> 
> mysql_num_rows();
> 


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




Re: [PHP-DB] RE: Search results

2002-02-06 Thread Chris Boget

> You can use mysql_result_rows() to check whether any rows were returned;
> something like:

you mean:

mysql_num_rows();

?

Chris


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




[PHP-DB] RE: Search results

2002-02-06 Thread Andrew Chase

You can use mysql_result_rows() to check whether any rows were returned;
something like:

 0){

while ($row = mysql_fetch_array($result)) {

//Do stuff with result rows here

}

}else{

echo "Sorry your search returned Zero Rows";

}

?>

HTH,

-Andy

> -Original Message-
> From: Todd Williamsen [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 06, 2002 10:17 AM
> To: [EMAIL PROTECTED]
> Subject: Search results
>
>
> I have done a search page based on a specific column name, but in some
> columns there is no results to be returned..
>
> What I would like to do is display an error message stating that
> there is no
> results .. something like "Sorry your search returned Zero Rows"
>


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




[PHP-DB] Re: Search Results - Next 10 records

2001-09-03 Thread Dennis Butler

Thanks very much Marcus.  It worked like a charm.

Dennis

On Mon, 3 Sep 2001 14:02:07 +0200, [EMAIL PROTECTED] (Marcus Tobias) wrote:
> Hi Dennis!
> 
> You can add the parameter "LIMIT" to your SQL query.
> Syntax: LIMIT $start_record,$record_count
> Example: $query_string = "select * from $table where keywords like
> '%$keyword%' limit 5,3";
> This will return 3 records started with the 5. found record.
> 
> The startrecord has to increase on next page.
> Store the current startrecord in the form and send it to the next page.
> 
> bye Marcus
> 
> 
> "Dennis" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Trying to figure out how to limit search results to say 10 records and
> produce
> > a button to show the next 10.  Do you use PHP to do the logic, or should I
> make
> > another table column for a temporary count?  This is what I'm up to so
> far...
> >
> > Thanks in advance
> >
> >
> > function show_all($table, $keyword=0)// initialize to zero
> > {
> 
> global $start_record;
> 
> if ( !isset( $start_record ) ) $start_record = 0;
> 
> >   $query_string = "select * from $table where keywords like '%$keyword%'";
> 
> $query_string = "select * from $table where keywords like '%$keyword%' limit
> $start_record,10";
> 
> 
> >   $entire_table = mysql_query($query_string);
> >   $count = 0;
> >   print("\n");
> > while ($cols_rows = mysql_fetch_array($entire_table)) {
> >  $count++;
> >   if ($count < 4){
> > print("");
> > print("");
> > print("");
> > print ($cols_rows['num']);
> > print("");
> > print("");
> > print ($cols_rows['site_name']);
> > print("");
> > print("");
> > print ($cols_rows['keywords']);
> > print("");
> > print("");
> > print ($cols_rows['url']);
> > print("");
> >   }
> >
> > if ($count > 3){
> > print("");
> > print("");
> > print("");
> > print ($cols_rows['num']);
> > print("");
> > print("");
> > print ($cols_rows['site_name']);
> > print("");
> > print("");
> > print ($cols_rows['keywords']);
> > print("");
> > print("");
> > print ($cols_rows['url']);
> > print("");
> > $count++;
> >   }
> >   }
> >
> > print ("");
> 
> print("");
> 
> > print ("");
> >   print $count;
> > print("\n");
> > }
> >
> >
> > ?>
> >
> 
> 



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Re: Search Results - Next 10 records

2001-09-03 Thread hassan el forkani

hi

...and to be able to know the exact number of pages
do
$result = mysql_query("select count(*)");
$nb_pages = $result/$nb_records_per_page;
et voila! add this to marcus's suggestion and you have a full paging script,
if you want some inspiration check out http://phpclasses.upperdesign.com i 
believe they have a class that does exactly that;

regards

At 14:02 03/09/01, Marcus Tobias wrote:
>Hi Dennis!
>
>You can add the parameter "LIMIT" to your SQL query.
>Syntax: LIMIT $start_record,$record_count
>Example: $query_string = "select * from $table where keywords like
>'%$keyword%' limit 5,3";
>This will return 3 records started with the 5. found record.
>
>The startrecord has to increase on next page.
>Store the current startrecord in the form and send it to the next page.
>
>bye Marcus
>
>
>"Dennis" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Trying to figure out how to limit search results to say 10 records and
>produce
> > a button to show the next 10.  Do you use PHP to do the logic, or should I
>make
> > another table column for a temporary count?  This is what I'm up to so
>far...
> >
> > Thanks in advance
> >
> >
> > function show_all($table, $keyword=0)// initialize to zero
> > {
>
> global $start_record;
>
> if ( !isset( $start_record ) ) $start_record = 0;
>
> >   $query_string = "select * from $table where keywords like '%$keyword%'";
>
>$query_string = "select * from $table where keywords like '%$keyword%' limit
>$start_record,10";
>
>
> >   $entire_table = mysql_query($query_string);
> >   $count = 0;
> >   print("\n");
> > while ($cols_rows = mysql_fetch_array($entire_table)) {
> >  $count++;
> >   if ($count < 4){
> > print("");
> > print("");
> > print("");
> > print ($cols_rows['num']);
> > print("");
> > print("");
> > print ($cols_rows['site_name']);
> > print("");
> > print("");
> > print ($cols_rows['keywords']);
> > print("");
> > print("");
> > print ($cols_rows['url']);
> > print("");
> >   }
> >
> > if ($count > 3){
> > print("");
> > print("");
> > print("");
> > print ($cols_rows['num']);
> > print("");
> > print("");
> > print ($cols_rows['site_name']);
> > print("");
> > print("");
> > print ($cols_rows['keywords']);
> > print("");
> > print("");
> > print ($cols_rows['url']);
> > print("");
> > $count++;
> >   }
> >   }
> >
> > print ("");
>
>print("");
>
> > print ("");
> >   print $count;
> > print("\n");
> > }
> >
> >
> > ?>
> >
>
>
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: Search Results - Next 10 records

2001-09-03 Thread Marcus Tobias

Hi Dennis!

You can add the parameter "LIMIT" to your SQL query.
Syntax: LIMIT $start_record,$record_count
Example: $query_string = "select * from $table where keywords like
'%$keyword%' limit 5,3";
This will return 3 records started with the 5. found record.

The startrecord has to increase on next page.
Store the current startrecord in the form and send it to the next page.

bye Marcus


"Dennis" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Trying to figure out how to limit search results to say 10 records and
produce
> a button to show the next 10.  Do you use PHP to do the logic, or should I
make
> another table column for a temporary count?  This is what I'm up to so
far...
>
> Thanks in advance
>
>
> function show_all($table, $keyword=0)// initialize to zero
> {

global $start_record;

if ( !isset( $start_record ) ) $start_record = 0;

>   $query_string = "select * from $table where keywords like '%$keyword%'";

$query_string = "select * from $table where keywords like '%$keyword%' limit
$start_record,10";


>   $entire_table = mysql_query($query_string);
>   $count = 0;
>   print("\n");
> while ($cols_rows = mysql_fetch_array($entire_table)) {
>  $count++;
>   if ($count < 4){
> print("");
> print("");
> print("");
> print ($cols_rows['num']);
> print("");
> print("");
> print ($cols_rows['site_name']);
> print("");
> print("");
> print ($cols_rows['keywords']);
> print("");
> print("");
> print ($cols_rows['url']);
> print("");
>   }
>
> if ($count > 3){
> print("");
> print("");
> print("");
> print ($cols_rows['num']);
> print("");
> print("");
> print ($cols_rows['site_name']);
> print("");
> print("");
> print ($cols_rows['keywords']);
> print("");
> print("");
> print ($cols_rows['url']);
> print("");
> $count++;
>   }
>   }
>
> print ("");

print("");

> print ("");
>   print $count;
> print("\n");
> }
>
>
> ?>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]