If all of this code is in one PHP file, then you only need the first 
session_start() function call on line 2 and you can delete all the other 
calls to session_start().

Best regards,
Jim @ iDimensionz.com
-- 
http://www.iDimensionz.com Professional web site design and affordable 
web site hosting.
------------------------------------------------------------------------
Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&id=38044&t=84> 
– Get the new open source web browser, FireFox, and enjoy features like 
pop up blocking, tabbed browsing and MUCH more!
Get Thunderbird! 
<http://www.spreadfirefox.com/?q=affiliates&id=38044&t=178> – Get the 
new open source e-mail client, ThunderBird, and enjoy features like 
integrated spam filter, privacy protection, integrated RSS reader and 
MUCH more!

sumanth kiuumar wrote:

> Hi everyone,
> First i m thanking everyone who helped me in solving the problems 
> which i posted b4.
> I ve placed the search functionality code below.The problem with the 
> code is,if i assign the searchvariable (marked in red colour) within 
> the file itself then my code is working fine with the links above to 
> the next results(5 results per page).if i m getting the value from the 
> form then the links are not displayed.can anyone help me.
>
> <?php
> session_start();
> //paging defaults
> //$SEARCH_TEXT=$_POST['str'];
> //session_register('$SEARCH_TEXT');
> if(!$page){$page=1;}
> if(!$perpage){
> //$perpage can be passed in a query string to change the records per 
> page (?perpage=10)
> $perpage=5;//how many records per page default to 5
> }
> ?>
> <?
> session_start();
> function 
> page_records($page,$pagecount,$recordstart,$COLUMN_NAME,$SEARCH_TERM,$perpage){
>  
>
> ?>
> <table>
> <tr>
> <?php
> session_start();
> for ($i=1; $i <= $pagecount;$i++){
> if($i != $page){
> echo"<td>[<a 
> href=\"$PHP_SELF?search=1&COLUMN_NAME=$COLUMN_NAME&SEARCH_TERM=$SEARCH_TERM&page=$i&perpage=$perpage\">
>  
> $i </a>]</td>" ;
> }
> else
> {
> echo "<td style=\"color:silver;\">[ $i ]</td>";
> }
> }//end for
> ?>
> </tr>
> </table>
> <?
> }//end function
> ?>
> <?php
> session_start();
> //Assume $COLUMN_NAME and $SEARCH_TERM are variables passed from a 
> form or query string
> mysql_connect("localhost","root","password");
> mysql_select_db("login");
> $COLUMN_NAME="title";
> echo $SEARCH_TERM;
> $SEARCH_TERM="pneumatic";
> $query = "SELECT * FROM search2 WHERE $COLUMN_NAME = '$SEARCH_TERM'";
>
> $result = mysql_query($query);
> //get how many records are in your search
> $totalreturned = mysql_num_rows($result);
> //to get the pages divide how many records by howmany items per page
> $pagecount = ceil($totalreturned/$perpage);
> //get the record number we want to start from
> $recordstart = ($page-1)*$perpage;
>
> //send all the variables to page_records function
> //replace $SEARCH_TERM , $COLUMN_NAME with your variable name
> page_records($page,$pagecount,$recordstart,$COLUMN_NAME,$SEARCH_TERM,$perpage);
>  
>
>
> //finally do the search with the record range we want
> $query = "SELECT * FROM search2 WHERE $COLUMN_NAME LIKE 
> '%$SEARCH_TERM%' LIMIT $recordstart,$perpage";
> $result = mysql_query($query);
> $count=mysql_num_rows($result);
> echo "
> <tr bgcolor=blue>
>
> <td width=83%>title</td>
> </tr>
> <tr bgcolor=blue>
>
> <td width=83%>content</td>
> </tr>";
>
> echo "<br>";
> while($res=mysql_fetch_assoc($result))
> {
> $title=$res['title'];
> $content=$res['content'];
> echo "
> <tr bgcolor=blue>
>
> <td width=83%>&nbsp;$title</td>
> </tr>
> <tr bgcolor=purple>
>
> <td>&nbsp;$content</td>
> </tr>";
> echo "<br>";
>
>
> }
> //the rest of your code goes here
> ?>
>




The php_mysql group is dedicated to learn more about the PHP/MySQL web database 
possibilities through group learning.  
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php_mysql/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to