Jump to content

weird selection problem


apocra

Recommended Posts

Hi all,

I've got this weird problem which I can't seem to get rid off. I bet it will be some minor glitch I keep failing to notice, I hope someone here can help me.

I've got a database with multiple records (2 in the test-db) which I want to print onscreen in a table. But before that I want to check the id of the records with the id in a textfile. To do this I try to get the id's in a array (test-db has id #1 and #45) and am using the following code:

[code]$pid = mysql_query("SELECT id FROM profiel ORDER BY id ASC LIMIT $num")
or die('Could not find data in database ' . mysql_error());

$pid2 = mysql_fetch_array ($pid, MYSQL_NUM);
[/code]

($num = the number of rows in the db and I've checked this, it's 2)

The array $pid2 only has one id in it and not the 2 that are in the database.

Help would be very much appreciated.

Cheers,
Apocra
Link to comment
Share on other sites

mysql_fetch_array returns one row at a time.
[code]
$pid = mysql_query("SELECT id FROM profiel ORDER BY id ASC LIMIT $num")
or die('Could not find data in database ' . mysql_error());

while($pid2 = mysql_fetch_array ($pid, MYSQL_NUM))
{
    echo $pid2[0]."<br />\n";
}
[/code]
http://php.net/mysql_fetch_array
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.