Jump to content

vang163

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

vang163's Achievements

Member

Member (2/5)

0

Reputation

  1. there is nothing wrong with my pagination. All is ok. I'm only having problem with the data display for sorting order (asc/desc) in a single page.
  2. this is my code, i use a function to display the data. $limit - refers to the number of data rows display. eg. display 10 records per page $page - refers to the current page number. function displayData($tableName, $column, $direction, $limit, $page) { $set_limit = ($page * $limit) - $limit; $sql = "SELECT * FROM $tableName ORDER BY $column $direction LIMIT $set_limit, $limit"; $result = mysql_query($sql) or die('Query Failed.'); $count = mysql_num_rows($result); if ($count <= 0) { echo 'No match.'; } else if ($count > 0) { while($row = mysql_fetch_assoc($result)) { echo " <tr>"; echo " <td>" . $row['id'] . "</td>"; echo " <td>" . $row['tel'] . "</td>"; echo " <td>" . $row['fax'] . "</td>"; echo " <td>" . $row['Owner'] . "</td>"; echo " <td>" . $row['countryCode'] . "</td>"; echo " <td>" . $row['country'] . "</td>"; echo " </tr>"; } } }
  3. my initial question written on the other day was: hi, i've a table with 100 records. i displayed the data into 10 records per page, therefore i've 10 pages of data. using this query - "select * from table order by $column $direction limit $set_limit $limit_size" where $column is the table column name $direction - asc or desc Assuming i'm at page 1, I can view the display data (1,2,3,4..10) in ascending order by default. But when i want to display the data in descending order for page 1, I'm getting descending order data from page 10. I want to be able to see the page 1 data in ascending and in descending order. This applies to all other pages. (2,3,4...10) Can someone show me how this can be done, thanks. But i did not know what the other helpers are referring to. That is why i thought the problem lies with the sql statement. Your assistance in this matter is greatly appreciated, thanks.
  4. yes, please. I tried for last 3 days, but failed. only managed to sort it out for table column id, but not for other column which is in varchar field.
  5. i do not want to go back to the script and start editing each time i want to view different set of data in different order. appreciate if anyone could show me or point me the direction on how this can be done with the correct sql statement or logic, thanks.
  6. is there a formulae or logic so that i can view the result in any way i want but with only 1 sql statement? eg. view row 30~40 in ascending & descending order? view row 60~90 in ascending & descending order? ....
  7. i have 100 records in a table, how can i display data at row 11~20 in the descending order? eg. row 20 data row 19 data row 18 dtata ... ...
  8. $sql = "select * from table order by column desc limit 10,10"; i try this but it give me data of row 80~90 in descending order, not row 11~20... :'(
  9. hi, if i have 100 records in a table, how can i display data at row 11~20 in the descending order? eg. row 20 data row 19 data row 18 dtata ... ... What is the sql stement like? $sql = "select * from table order by desc limit 10,10"; ???
  10. hi, i have no idea how to dump the ASC results into an array, can you show me how? my initial idea was below but it does not work. $sql = "select * from table"; $result = mysql_query($sql); $asc = mysql_fetch_assoc($result); $reverse_result = array_reverse($asc);
  11. hi, i've a table with 100 records. i displayed the data into 10 records per page, therefore i've 10 pages of data. using this query - "select * from table order by $column $direction limit $set_limit $limit_size" where $column is the table column name $direction - asc or desc Assuming i'm at page 1, I can view the display data (1,2,3,4..10) in ascending order by default. But when i want to display the data in descending order for page 1, I'm getting descending order data from page 10. I want to be able to see the page 1 data in ascending and in descending order. This applies to all other pages. (2,3,4...10) Can someone show me how this can be done, thanks.
  12. function displayData($tableName) { $sql = "SELECT * FROM $tableName"; $result = mysql_query($sql) or die("Query Failed."); $count = mysql_num_rows($result); $number_of_column = mysql_num_fields($result); if ($count == 0) { echo 'No matches of your criteria.'; } else if ($count > 0) { for($j = 0; $j < $count; $j++) { echo " <tr>\r"; for($i = 0; $i < $number_of_column; $i++) { echo " <td>" . mysql_fetch_row($j, $i) . "</td>\r"; } echo " </tr>\r"; } } }
  13. hi, can you show me how to write a function that display all data in database, irregardless of the number of columns and rows in the database, thanks. I've tried for 2 days but failed.
  14. oh, i see what you mean. yes, the file will have to be upload first in the server. Then import the data.
  15. there are existing data in the database. i want to remove all existing data, then import all the data in the text file to the database. no need to upload the file to the server, just import data.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.