Re: help!! newbie

From: Date: Sun, 22 Apr 2001 05:40:22 +0000
Subject: Re: help!! newbie
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-49717@lists.php.net to get a copy of this message
then, should i do this? --- $query = "SELECT * FROM refer ORDER BY hits desc LIMIT $i,$end"; $result = mysql_db_query ("celebzone", $query); $num = mysql_num_rows($result); echo $num; for ($i; $i < $end; $i++) { $r = mysql_fetch_array($result,$i); $id = $r[id]; $title = $r[title]; // $id = mysql_result($result, $i, "id"); // check this later // $title = mysql_result($result, $i, "title"); // check this later echo "<a href=\"http://www.celebritieszones.com/jump.php?id=$id\">$title</a><br>\n"; } -------------- it didn't work. it says "Warning: Supplied argument is not a valid MySQL result resource in /home/sites/site3/web/links/index.php on line 15" why? ""Plutarck"" <aemuli@spamclause-yahoo.com> wrote in message news:9bte0p$53d$1@toye.p.sourceforge.net... > You'll want to use the LIMIT option in SQL. So on the end of your query add: > > "LIMIT 0,10" to get the first ten results. > > The first number is the "offset", and the last is the max amount to > retrieve. To get links 20 through 40 you'd use: > > "LIMIT 19, 39" > > The offset is refering to an array, so offset 0 is actually the first link. > > > -- > Plutarck > Should be working on something... > ...but forgot what it was. > > > ""McShen"" <webmaster@celebritieszones.com> wrote in message > news:9btbqt$t79$1@toye.p.sourceforge.net... > > hi > > > > I have 30 links stored in a table(mysql) now. I wanna show them accorging > to > > the traffic they send. But i don't want to list all of them in just 1 page > > because i will be adding 300 links soon. (I don't want my visitors to wait > 3 > > minutes to load the links)How should i do it? I wanna do it like this > > http://mydomain.com/links?list=0 > > shows only links from 0-15 > > and > > http://mydomain.com/links?list=15 > > shows links from 15-30 > > etc. > > > > here is my code. > > ------ > > <?php > > > > $connection = mysql_connect("localhost","",""); > > if ($connection==false) > > { > > echo mysql_errno().":".mysql_error().""; > > exit; > > } > > $query = "SELECT * FROM refer ORDER BY hits desc "; > > $result = mysql_db_query ("celebzone", $query); > > > > $rows = mysql_num_rows($result); > > $num_of_page = floor($rows/15)+1; > > > > $i=$list; > > > > for ($i = $list; $i < $list+15; $i++) > > { > > > > if ($i <= $rows) > > { > > @$id = mysql_result($result, $i, "id"); // check this later > > @$title = mysql_result($result, $i, "title"); // check this later > > echo "<a > href=\"http://www.celebritieszones.com/jump.php?id=$id\">$title</a><br>\n"; > > > > } > > else > > { > > echo "<!-- Cute Celebrities Links -->"; > > $i = 288; // this forces it to quit the loop > > > > } > > } > > echo "<br>"; > > > > $check = floor($rows/$num_of_page); // this finds how many pages it should > generate > > if ( $check>0 ) > > { > > > > if (($i-1)==288) > > { > > echo "<!-- Cute Celebrities Links !-->"; > > } > > else > > { > > $num_of_page = $i; > > echo "<a > href=\"http://www.celebritieszones.com/links/index.php?list=$num_of_page\">N > ext Link Page</a>"; > > } > > > > } > > ?> > > ------- > > It's not good though and it's kinda stupid. :( When it loads the last page > of my links, it will show this > > "Warning: Unable to jump to row 48 on MySQL result index 2 in > /home/sites/site3/web/links/index.php on line 22 > > > > Warning: Unable to jump to row 48 on MySQL result index 2 in > /home/sites/site3/web/links/index.php on line 23" > > > > You see the @? I am using it to supress the error messasges cuz i don't > know how to fix this error. Please help. :) > > Thank You. > > > > > > > > > > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#49717) next »