Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
mysql_connect("localhost", "root", "pass") or 
  die("Could not connect: " . mysql_error());


$result = mysql_query("SELECT * FROM others");  
$row = mysql_fetch_row($result);
echo $row[0]; 

Each time I echo anything it shows number 1.

I don't know if there is a 1 stuck from other file in the input stream?

share|improve this question

closed as off topic by Tom Wijsman, random Apr 11 '12 at 2:43

Questions on Super User are expected to relate to computer software or computer hardware within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Welcome to Super User! Please don't use Super User for programming questions. Your question will automatically be migrated to Stack Overflow, our sister site for developers... – Tom Wijsman Apr 2 '12 at 22:07
How to show the whole row?? assume I have three column "id" "author" "topic". – Iman25 Apr 2 '12 at 22:08
Enumerate over $row with a for loop, so you get $row[1], $row[2] and so on. You might also be interested in the end of the example here for a better approach. I've posted a whole answer below... – Tom Wijsman Apr 2 '12 at 22:09
Thank you. It worked – Iman25 Apr 2 '12 at 22:15
Make sure to check the mysql_fetch_assoc together with extract($row), it makes it a lot easier. :) – Tom Wijsman Apr 2 '12 at 22:17

1 is the first value from the first row from your table.

Hint: Identity column.

Don't use * in queries, you'll end up selecting more data than you'll want, which is slower.

If you want to get all the values, enumerate over $row with a for loop.

You might also be interested in the end of the example here for a better approach:

// While a row of data exists, put that row in $row as an associative array
// Note: If you're expecting just one row, no need to use a loop
// Note: If you put extract($row); inside the following loop, you'll
//       then create $userid, $fullname, and $userstatus so you don't need $row.
while ($row = mysql_fetch_assoc($result)) {
    echo $row["userid"];
    echo $row["fullname"];
    echo $row["userstatus"];

// Make sure that we be nice to our valuable memory.
share|improve this answer
the code above is just to test but what I really want to do is to view each entry in the table from the db and put on table on webpage and put beside each row a radio bottom to modify the row. I'm in progress if you have any info that could help. I intend to build simlp cms – Iman25 Apr 3 '12 at 2:20
@lman25: Feel free to ping me on chat (type @Tom) in – Tom Wijsman Apr 3 '12 at 6:45

Not the answer you're looking for? Browse other questions tagged .