Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

strange issue of mysql query and array

Links for php scripts

Moderators: macek, egami, gesf

strange issue of mysql query and array

Postby bartsimpson » Thu Nov 07, 2013 7:02 am

I have a strange issue in this script.
There is a table of primenumbers. and when selecting them in Asc. order to populate the array it removes the 1st entry (no. 3 (prime)). But is always there when selecting the records in Desc. order.
I just can't figure it out why?

here is part of the code.
Code: Select all
$inputNumber    = 69;
$primedataArray = array();

 
$query = "SELECT * FROM primesets where primenumber <= " . $inputNumber . " order by primenumber asc" ;
$data = mysql_query($query)  or die(mysql_error());

/* Get all Records from the table upto the Input number */
$dataArray = mysql_fetch_array( $data ) ;

while($dataArray = mysql_fetch_array( $data ))
{
  $primedataArray[] = $dataArray['primenumber'];
}

echo "<pre>";
  print_r ($primedataArray) ;
echo "</pre>";


And yes the table has value 3 in there. The first record itself.
Can anyone shed some light here please?

Thanks,
(pseudo)Bart Simpson
bartsimpson
New php-forum User
New php-forum User
 
Posts: 1
Joined: Thu Nov 07, 2013 6:14 am

Return to PHP Scripts

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.