Jul 7, 2008

How To Read Specific Row From Table - according where no=xx

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

How To Read Specific Row From Table - according where no=xx

kakingho
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??

Reply

Arne-Christian
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

Reply

HmmZ
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

 

 

 


Reply

kakingho
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?

Reply

leiaah
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];
}

Reply

kakingho
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

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : specific xx

  1. Directing To A User To Specific Page First Time Only - (3)
  2. Replace A Character In A Specific Tag - (7)
    I need a code that replaces all spaces between ] brackets with an underscore. So, basically, I
    write this into a variable: CODE bla bla something [[some text]] more text here
    And I want a script to change it to this: CODE bla bla something [[some_text]]
    more text here Any suggestions?...



Looking for read, specific, row, table, xx

Searching Video's for read, specific, row, table, xx
advertisement



How To Read Specific Row From Table - according where no=xx



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE