Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> How To Read Specific Row From Table, according where no=xx
kakingho
post Dec 26 2005, 03:46 PM
Post #1


Member [Level 1]
****

Group: Members
Posts: 52
Joined: 17-July 05
From: hong kong
Member No.: 9,520



For example...
a table have 2 columns, 100 rows
for column i.e. no, name


I want to get corresponding name when no=17

How to write this php coding??
Go to the top of the page
 
+Quote Post
Arne-Christian
post Dec 26 2005, 04:02 PM
Post #2


Member [Level 1]
****

Group: Members
Posts: 62
Joined: 22-December 05
From: Sandefjord,Norway
Member No.: 16,078



An idea could be to Click Here: http://php.about.com/library/bl-addtut03.htm
There you find a tutorial about that, just rewrite a little on that script and it will problety work, Hope i Helped biggrin.gif

~ Arne-Christian
Go to the top of the page
 
+Quote Post
HmmZ
post Dec 27 2005, 12:46 AM
Post #3


Super Member
*********

Group: Members
Posts: 362
Joined: 2-March 05
From: The Netherlands
Member No.: 4,097



Not too hard:

CODE

print "<tr><td>Column 1</td><td>Column 2</td></tr>";
$query = mysql_query("SELECT * FROM table");
while($getArray = mysql_fetch_array($query)){
print "<tr><td>$getArray[number]</td><td>$getArray[name]</td></tr>";}

Note that while{} is an ongoing loop, it will load any number of records

wich will display a full list* of each record, showing number and the name attached to it.

* To limit the number of results change the query by:
CODE
$query = mysql_query("SELECT * FROM table LIMIT 10

the above code would limit the number of results (rows) to 10

* To order the number of results change the query by:
CODE
$query = mysql_query("SELECT * FROM table ORDER BY number DESC");

the above code would order the list by number descending

* To do both:
CODE
$query = mysql_query("SELECT * FROM table ORDER BY number DESC LIMIT 10");


any questions ill gladly answer
Go to the top of the page
 
+Quote Post
kakingho
post Dec 27 2005, 03:15 PM
Post #4


Member [Level 1]
****

Group: Members
Posts: 52
Joined: 17-July 05
From: hong kong
Member No.: 9,520



QUOTE(HmmZ @ Dec 27 2005, 08:46 AM)
Not too hard:

CODE

print "<tr><td>Column 1</td><td>Column 2</td></tr>";
$query = mysql_query("SELECT * FROM table");
while($getArray = mysql_fetch_array($query)){
print "<tr><td>$getArray[number]</td><td>$getArray[name]</td></tr>";}

Note that while{} is an ongoing loop, it will load any number of records

wich will display a full list* of each record, showing number and the name attached to it.

* To limit the number of results change the query by:
CODE
$query = mysql_query("SELECT * FROM table LIMIT 10

the above code would limit the number of results (rows) to 10

* To order the number of results change the query by:
CODE
$query = mysql_query("SELECT * FROM table ORDER BY number DESC");

the above code would order the list by number descending

* To do both:
CODE
$query = mysql_query("SELECT * FROM table ORDER BY number DESC LIMIT 10");


any questions ill gladly answer
*


Your method is good to deal with large data.
Are there any other easy methods to show only 1 record with corresponding no. easily?
Go to the top of the page
 
+Quote Post
leiaah
post Dec 27 2005, 03:39 PM
Post #5


Super Member
*********

Group: Members
Posts: 436
Joined: 21-January 05
From: Koronadal City, Philippines
Member No.: 3,358



Try this code. It might help.

CODE
$db = mysql_connect ("localhost", "username", "password");
mysql_select_db ("database_name");

$query=mysql_query("SELECT field1,field2 FROM table WHEN no=17");

while($row=mysql_fetch_row($query)){
    echo $row[0].'<br>'.$row[1];
}
Go to the top of the page
 
+Quote Post
kakingho
post Dec 29 2005, 04:31 PM
Post #6


Member [Level 1]
****

Group: Members
Posts: 52
Joined: 17-July 05
From: hong kong
Member No.: 9,520



QUOTE(leiaah @ Dec 27 2005, 11:39 PM)
Try this code.  It might help.

CODE
$db = mysql_connect ("localhost", "username", "password");
mysql_select_db ("database_name");

$query=mysql_query("SELECT field1,field2 FROM table WHEN no=17");

while($row=mysql_fetch_row($query)){
    echo $row[0].'<br>'.$row[1];
}

*



thx a lot laugh.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Read This Before Applying For Hosting!(58)
  2. Last Book You Read?(199)
  3. Beside novel or friction, what do you read?(5)
  4. **** Read Before You Post! ****(48)
  5. Read This At Any Cost Before Posting Here(8)
  6. Im Making A Mmorpg >>(14)
  7. Read-only Folders In Xp(13)
  8. Sendearnings.com(17)
  9. Ie Table Width In A Div Tag(5)
  10. Adding Rows & Columns In Html Table Using Javascript(1)
  11. Dvd Drive Problem(10)
  12. Tracking My Stolen Laptop(8)
  13. Eragon(54)
  14. Read File (.txt) On Another Website Using Jsp?(3)
  15. Who Is The Best Writer Did You Ever Read And His Or Her Book(11)
  1. Free Wap! Omg!(4)
  2. Living Everyday Happily And Meaningfully(5)
  3. Can You Read In Your Dreams?(24)
  4. Hackers Hijack A Half-million Sites: Phpbb Forum Users Must Read(8)
  5. Ftp Access Has Stopped Working All Of A Sudden [resolved](5)
  6. Cpanel Raw Acess Log(1)
  7. Free Web Hosting Application [screened] [approved](6)
  8. Can't Read E-mail(0)
  9. Compatibility/major Question(5)
  10. Trap17 Gets Supernatural: Topics Disappear!(7)
  11. Firefox And Ie: Table Layouts Look Different In Us!(3)
  12. Mac To Read Microsoft Word(3)
  13. Welcome All New Registered Users Of Trap17(0)


 



- Lo-Fi Version Time is now: 8th October 2008 - 05:41 AM