/    Sign up×
Community /Pin to ProfileBookmark

Displayin the whole table

I want to display the all the values in the column
it is only displaying the first value. i have 5 value inside that colum..
i think that there is something wrong witht the loop, i just dont seem to find the problem.. thank u

[code=php]

<?
$host = “localhost”;
$username = “localhost”;
$password = “abc123”;
$database = “contacts”;

$db = mysql_connect($host, $username, $password);
mysql_select_db($database);

$result=mysql_query($query);

$result = mysql_query(“SELECT * FROM `First Name:` WHERE `Position:`=`Position:`”
,$db) or die(mysql_error());

$myvar= “Hello World<br>”;
printf(“$myvar”);

$num_result = mysql_num_rows($result);

echo “Number of Results Found:” .($num_rows = mysql_num_rows($result));

$num_result = mysql_num_rows($result);

for($i=0; $i <$num_result; $i++)
{
$row = mysql_fetch_assoc($result);

printf(” <br>Position: %s<br>n”, mysql_result($result,0,”Position:”));

}

?>

[/code]

displaying

Hello World
Number of Results Found:5
Position: owner

Position: owner

Position: owner

Position: owner

Position: owner

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@porkyJun 02.2006 — try to add this row

print_r($row);

after

printf(" <br>Position: %s<br>n", mysql_result($result,0,"Position:"));


to see an all data in row
Copy linkTweet thisAlerts:
@NogDogJun 02.2006 — [code=php]
$result = mysql_query("SELECT * FROM First Name: WHERE Position:=Position:"
,$db) or die(mysql_error());

echo "Number of Results Found: " . mysql_num_rows($result);

while($row = mysql_fetch_assoc($result))
{
printf(" <br>Position: %s<br>n", $row["Position:"]);
}
[/code]
Copy linkTweet thisAlerts:
@Li0rEJun 02.2006 — because your using mysql_fetch_assoc and not mysql_fetch_array.

And, if you use a while statement, it isnt a for loop, so at the end, you have to write $row_count++

AND, on your for loop, you can't use mysql_result in a for loop unless you display the row of the result you want, so you need mysql_result($result,$i,"Position:")

Come on, get with the program ?
×

Success!

Help @franknu spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...