Jump to content

Recommended Posts

How can I limit the number of rows displayed by the code below?

 

$display = '
<table class="fixt-res">
	<thead>
		<tr>
			<th>Date</th>
			<th>Team</th>
                <th>Versus</th>
			<th>Time</th>
			<th>Venue</th>
		</tr>
	</thead>
	';
	while($mrow = mysql_fetch_array($mresult)) {
		$display .= '<tr>';
			$display .= '<td class="fixt-res">'.date('d/m/Y', strtotime($mrow['matchdate'])).'</td>';
                $display .= '<td class="fixt-res">';
				$sqlcode = "SELECT * FROM $tbl_grade WHERE `gradeID` = '".$mrow['grade']."' LIMIT 1";
				$resultcode = mysql_query($sqlcode);
				$rowcode = mysql_fetch_array($resultcode);
				$display .= $rowcode['gradename'];
			$display .= '</td>';
                    $display .= '<td class="fixt-res">';
				$sqlcode = "SELECT * FROM $tbl_team WHERE `teamID` = '".$mrow['team2']."' LIMIT 1";
				$resultcode = mysql_query($sqlcode);
				$rowcode = mysql_fetch_array($resultcode);
				$display .= $rowcode['teamname'];
			$display .= '</td>';
			if(date('H:i', strtotime($mrow['matchtime'])) == '00:00')
				$display .= '<td class="fixt-res"><acronym title="To Be Decided">TBD</acronym></td>';
			if(date('H:i', strtotime($mrow['matchtime'])) != '00:00')
				$display .= '<td class="fixt-res">'.date('H:i', strtotime($mrow['matchtime'])).'</td>';
                $display .= '<td class="fixt-res">';
				$sqlcode = "SELECT * FROM $tbl_venue WHERE `venueID` = '".$mrow['matchvenue']."' LIMIT 1";
				$resultcode = mysql_query($sqlcode);
				$rowcode = mysql_fetch_array($resultcode);
				$display .= $rowcode['venuename'];
			$display .= '</td>';
		$display .= '</tr>';
	}
	$display .= '</table>';
	return $display;
	?> 
</table>

To further clarify requinix, You limit the rows from a database with a LIMIT clause in the query.

 

SELECT * FROM table LIMIT 10 <-returns first 10 rows.
SELECT * FROM table LIMIT 10,10 <- starts rows at row 10, returns 10 rows.

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.