|
Posted by Claudio Corlatti on 10/03/07 15:08
On 3 oct, 11:41, Lamer <Galat...@gmail.com> wrote:
> How do I retrieve only one row of database info? here's what I have so
> far
>
> <?php
> $db_host = "localhost";
> $db_user = "username";
> $db_pwd = "password";
> $db_name = "dbname";
> mysql_connect($db_host, $db_user, $db_pwd);
> mysql_select_db($db_name);
> ?>
> <table>
> <?php
> $sql = "SELECT * FROM colors";
> $query = mysql_query($sql);
> while($row = mysql_fetch_array($query)) {
> echo "<tr>";
> echo "<td>".$row['name']."</td>";
> echo "<td>".$row['favoriteColor']."</td>";
> echo "</tr>";}
>
> ?>
> </table>
> </body>
> </html>
>
> Any help would be great. Thanks again!
Hello,
well i didn't understand your question very well, but i suppose that
you want to obtain just one row from the table "colors".
to do that you need to add a "where" clause in your mysql query, for
instance "select * from colors where idColor=1"
or you can remove the while and keep only the line $row =
mysql_fetch_array($query); but is not the best way.
bye
Claudio
[Back to original message]
|