php limitations

Reply

Join Date: Nov 2008
Posts: 7
Reputation: spokie is an unknown quantity at this point 
Solved Threads: 0
spokie spokie is offline Offline
Newbie Poster

php limitations

 
0
  #1
Dec 12th, 2008
Hey guys thank you for the help you have been giving me it is much appreciated!!! Now can someone help with some code, im developing a website using php and mysql and id like to know how do you limit the amount of data that the php script takes from the database??? And another problem i have is that it repeates the data that is contained in the table!! How do i stop that??? Im really a novice when it comes to this!!
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: php limitations

 
0
  #2
Dec 12th, 2008
can you post the code so we can see what you did wrong?

if you are wanting to limit the number of results returned from a mysql query you can use the LIMIT parameter.

to remove duplilcates you can use the DISTINCT param in the query as well.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 94
Reputation: sikka_varun is an unknown quantity at this point 
Solved Threads: 11
sikka_varun's Avatar
sikka_varun sikka_varun is offline Offline
Junior Poster in Training

Re: php limitations

 
0
  #3
Dec 12th, 2008
Hiiii.....
You can use the limit option that is available in SQL queries to limit the amount of data returned from the website....
For eg:

  1. SELECT * FROM mytable WHERE category='computers' ORDER BY name asc LIMIT 0,20

The above SQL query will show 20 records beginning from 1st record...

You can search more from google on the limit option... It will give u more examples...

As far as repeating of data is concerned... What i understand from your post is that... Your table is populated with exactly same data.. or in other words, the similar records can be entered more than once...
Correct me if im wrong..

For this, preferably write a small function that will check from the table whether the data already exists..
For eg. an employee details.. no two employees with same employee id can exists..

So you can use the similar function...
  1. <?php
  2. function check_employee_exists($emp_no)
  3. {
  4. $sql="Select * from employee where empid=".$emp_no;
  5. $result=mysql_query($sql);
  6. if(mysql_num_rows($result) > 0)
  7. {
  8. //means employee exists
  9. return true;
  10. }
  11. {
  12. //means employee details does not exists
  13. return false;
  14. }
  15. }
  16. ?>


This is done from PHP...

you can also set primary keys in the database table if you want to prevent duplicate data in the table...

If im on right path.. then post here... so that more options can be explored for this...
VâRûN
---Happy to Help---
sikka_varun@yahoo.com
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC