[PHP-DB] order by group by...
hi, i am trying to build a message board in php with mysql as back end; what i want to do is to query the database in a certain way that the result is returned in the correct order for php to display the discussion thread properly here is my table structure: mysql show fields from posts - ; +-+-+--+-+-++ | Field | Type | Null | Key | Default | Extra | +-+-+--+-+-++ | msgid | bigint(20) unsigned | | PRI | NULL | auto_increment | | dateadded | timestamp(14) | YES | | NULL | | | subject | mediumblob | | | | | | body | longblob | YES | | NULL | | | replytopost | bigint(20) unsigned | YES | | 0 | | | aposition | tinyint(3) unsigned | YES | | 0 | | | thrid | bigint(20) unsigned | | MUL | 0 | | | usrid | bigint(20) unsigned | | MUL | 0 | | | username | varchar(50) | | | | | +-+-+--+-+-++ 9 rows in set (0.00 sec) the query should look like : select * from posts where thrid = 'the id of the thread' order by.(this is the part i couldn't figure out); the position of a single message into the tree is determined by the following criteria: dateadded : the date in which it was added replytopost: the post to which it belongs, if none then 0 is assigned aposition: the absolute position of the message (horizontal) a combination of these columns in an order by clause should (in theory) build the tree correctly please advise me if i am doing something wrong here, i have tried many combinations without success regards; hassan -- 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
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(TABLE BORDER=1 width=700\n); while ($cols_rows = mysql_fetch_array($entire_table)) { $count++; if ($count 4){ print(tr); print(td bgcolor=azure); print(font size=3); print ($cols_rows['num']); print(/tdtd bgcolor=azure); print(font size=2); print ($cols_rows['site_name']); print(/tdtd bgcolor=azure); print(font size=2); print ($cols_rows['keywords']); print(/tdtd bgcolor=azure); print(font size=2); print ($cols_rows['url']); print(P/td); } if ($count 3){ print(tr); print(td bgcolor=silver); print(font size=3); print ($cols_rows['num']); print(/tdtd bgcolor=silver); print(font size=2); print ($cols_rows['site_name']); print(/tdtd bgcolor=silver); print(font size=2); print ($cols_rows['keywords']); print(/tdtd bgcolor=silver); print(font size=2); print ($cols_rows['url']); print(/td); $count++; } } print (FORM METHOD='POST' ACTION='search1.php'); print(INPUT TYPE='text' NAME='start_record' VALUE='$start_record+10'); print (INPUT TYPE='submit' VALUE='Next'/FORM); print $count; print(/TABLE\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] order by group by...
hi, i am trying to build a message board in php with mysql as back end; what i want to do is to query the database in a certain way that the result is returned in the correct order for php to display the discussion thread properly here is my table structure: mysql show fields from posts - ; +-+-+--+-+-++ | Field | Type | Null | Key | Default | Extra | +-+-+--+-+-++ | msgid | bigint(20) unsigned | | PRI | NULL | auto_increment | | dateadded | timestamp(14) | YES | | NULL | | | subject | mediumblob | | | | | | body | longblob | YES | | NULL | | | replytopost | bigint(20) unsigned | YES | | 0 | | | aposition | tinyint(3) unsigned | YES | | 0 | | | thrid | bigint(20) unsigned | | MUL | 0 | | | usrid | bigint(20) unsigned | | MUL | 0 | | | username | varchar(50) | | | | | +-+-+--+-+-++ 9 rows in set (0.00 sec) the query should look like : select * from posts where thrid = 'the id of the thread' order by.(this is the part i couldn't figure out); the position of a single message into the tree is determined by the following criteria: dateadded : the date in which it was added replytopost: the post to which it belongs, if none then 0 is assigned aposition: the absolute position of the message (horizontal) a combination of these columns in an order by clause should (in theory) build the tree correctly please advise me if i am doing something wrong here, i have tried many combinations without success regards; hassan -- 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] Getting info from Cookie
$http_cookie_vars['name_of_cookie'] At 09:57 15/08/01, Cato Larsen wrote: Hi! How can you extract a certain form of info from a Cookie? Im my case the cookie name is crispy. It has been stored with a session id and a charnick. How do I extract the charnick and use it in the page as $charnick or similar? Best Regards Cato Larsen -- 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]
Re: [PHP-DB] True and Flase in mysql !!
you could also use a char(0) field in which case you can only have two possible records: NULL and ' ' (empty string) regards 09/05/01 22:42:04, Zak Greant [EMAIL PROTECTED] wrote: Use an enum field. --zak - Original Message - From: DesClub.com [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, May 10, 2001 2:43 AM Subject: [PHP-DB] True and Flase in mysql !! hi all .. What is the best way to create True\Flase field in mysql ?? - http://deslcub.com/phpLinkat/ DesClub.com -- 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]