Increase load time of webpage by shortening code.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

shaunak1234
Forum Newbie
Posts: 13
Joined: Thu Nov 03, 2011 12:24 am

Re: Increase load time of webpage by shortening code.

Post by shaunak1234 »

Code: Select all

<?php
$data = mysql_query("SELECT `Name` FROM users ORDER BY srno ASC LIMIT 60" )
or die(mysql_error());
$per_page = 10;
$offset = (intval($_GET['page']) - 1) * $per_page;
$query = "SELECT 'Name' FROM users WHERE srno LIMIT $offset, $per_page";
while($info = mysql_fetch_array( $data))
{
Print"<a target='view' height='10' width='10' href='http://wallpapers.everything.org.in/images/".$info['Name']."'> <img src='images/".$info['Name'] . "' height='90' width='90'></a>";
}
ob_end_flush();
?>
Okay I put the above code in my php code it doesnt show up any thing!
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Increase load time of webpage by shortening code.

Post by Celauran »

I think you took my suggestion a little too literally. You're clearly not making any use of $per_page, $offset, or $query. $query is broken anyways; you need backticks around the column name, not single quotes.

I couldn't say why your initial query isn't working. What does mysql_num_rows($data) tell you? var_dump($data)?
Post Reply