 |
Results from the most recent live auction are here.
21 members in the live chat room. Join Chat!
| |
06-20-2008, 09:23 AM
|
· #1 | | An American Soldier Name: Ray Location: Pennsylvania Join Date: Jun 2005
Posts: 1,521
NP$: 347.25 ( Donate)
| php/mysql help -----SOLVED---------
I am in the middle of creating a search by letter script, except, i have ran into some trouble..
i want the user to be able to click a letter and it show all the results with that letter. no problem.. already done using.. PHP Code: $alp=$_GET[a];
while($row = mysql_fetch_array( $result )) {
$word= $row['title'];
$id=$row['id'];
$ab = substr($word, 0, 1);
$str = strtolower($ab);
if($alp != $str){
}
else{
echo ("<br>" . $id ."-<a href=\"$id/\">" . $data[0] . "</a>");
}
But, now, i want to make a paging script to page the data, but i cannot due that because i cannot count the mysql data in this way. I do not know how to and i am soo confused. every time i make a paging function i used a mysql count
this is what i believe it would have to look like but, we no its not going to work.. lol PHP Code: select title where title="substr($word, 0, 1)"
__________________
-- Afghanistan --
Last edited by -Ray- : 06-20-2008 at 10:07 AM.
|
| |
06-20-2008, 09:33 AM
|
· #2 | | Traveller Location: In an airport, probably Join Date: Mar 2007
Posts: 1,347
NP$: 573.28 ( Donate)
| |
| |
06-20-2008, 09:38 AM
|
· #3 | | An American Soldier Name: Ray Location: Pennsylvania Join Date: Jun 2005
Posts: 1,521
NP$: 347.25 ( Donate)
| thanks.. ill try that...
__________________
-- Afghanistan --
|
| |
06-20-2008, 09:41 AM
|
· #4 | | Traveller Location: In an airport, probably Join Date: Mar 2007
Posts: 1,347
NP$: 573.28 ( Donate)
| |
| |
06-20-2008, 09:48 AM
|
· #5 | | An American Soldier Name: Ray Location: Pennsylvania Join Date: Jun 2005
Posts: 1,521
NP$: 347.25 ( Donate)
| i trying it on function one... it worked... im trying it on function 2 now
final code... works... thanks PHP Code: <?php
$alp=$_GET[a];
require("pagerclass.php");
$limit="20";
mysql_connect("localhost", "------------") or die(mysql_error());
mysql_select_db("---------") or die(mysql_error());
$p = new Pager;
$start = $p->findStart($limit);
$count = mysql_num_rows(mysql_query("SELECT * FROM drink WHERE LEFT(title,1) = '$alp'"));
$pages = $p->findPages($count, $limit);
$pagelist = $p->pageList($_GET['page'], $pages, $urlqry);
echo $pagelist;
$result = mysql_query("SELECT title,id FROM drink where LEFT(title,1) = '$alp' ORDER BY title ASC LIMIT $start, $limit")
or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$word= $row['title'];
$id=$row['id'];
$data = explode(' recipe',$word);
echo ("<br>" . $id ."-<a href=\"$id/\">" . $data[0] . "</a>");
}
?>
__________________
-- Afghanistan --
Last edited by -Ray- : 06-20-2008 at 10:06 AM.
|
| |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | |