0

OK, this is an amateur question but I am having the most trouble displaying the values of my database. I want to display the entire 'phone' column so my mysql query is this:

$result = mysql_query('SELECT phone FROM contactList WHERE phone != 1') or die(mysql_error());
$row = mysql_fetch_array($result)

My PHP script is as this:

while(isset($rows))
{
echo $rows['phone'] . "html break tag";
}

It looks like though I'm only getting the first result instead of looping through the entire column.

Do I need to increment the ID in my loop and get value via ID? The only problem with that is my auto-incremental ID column starts @ 130 and skips some numbers here and there.

1 Answer 1

1

try this instead

While($row = mysql_fetch_array($result))
  echo $row['phone'];

That should help you looping through the whole array.

Sign up to request clarification or add additional context in comments.

2 Comments

@Howdy_McGee mysql_fetch_array() fetches all columns of one row into an array. In your case, one phone number ; )
Ohhhhh so by looping through all the rows I can pull the specific column that makes sense. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.