Hi all,

Been pulling my hair out on this one. I have a simple query:

$query = ("
			student_id = '$local_id'
			start_date= '20091023'
$result2 = $mysqli->query($query, MYSQLI_STORE_RESULT);

//$total_courses_I = $result2->num_rows; 
while ($obj2 = $result2->fetch_row())
		$course_code = $obj2[0];
		$ypos += 5;
		$data = $course_code ;	
		$pdf->SetXY($xpos, $ypos) ;
		$row_c ++;

start_date is a text field
According to PHPMYADMIN I have 4 courses for this date and student.
When I run this it only shows 3.

If I change the query from:
start_date= '20091023'
(SUBSTRING(start_date ,1,4) = '$school_year') //school year =2009

It then shows this missing course + plus others for other dates in 2009.

The start_date in phpmyadmin is 20091023 for 4 courses....

Why can't I query that exact string and get all four records?

Also if i uncomment num_rows then it says 4 too!!! But only three are shown

Re: Missing first row in query? 80 80

If mysql_num_rows say 4, then something must be wrong with your function, fetch_row. Post your function and we will try to find out what is missing.

Re: Missing first row in query? 80 80

Thanks for the reply.

The function fetch_row is a member function of mysqli class (improved extension of mysql). It should not be failing on this simple query.

The pdf is the popular free pdf php class. It should not have anything to do with this...i think.

Re: Missing first row in query? 80 80

My bad, sorry. I had never used mysqli. Thanks to you, I checked how it works and it did work.

$mysqli = new mysqli("localhost", "root", "", "test2");

if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());

$result = $mysqli->query("SELECT * from b");
echo "Total number of records: ".$result->num_rows."<br />";
while ($row = $result->fetch_row()) { 
	print "<pre>";
	print "</pre>";

Are you sure you are not overwriting the data in pdf ? If you print $obj2, does it print 4 records ?

Re: Missing first row in query? 80 80

Yeah there must be something fishing going on in fpdf...i will look into it and post here.

Re: Missing first row in query? 80 80

Okay, I took out the pdf class stuff and it works fine. I will head over to that forum...thanks for the help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.