[advanced search]
Results from the most recent live auction are here.
21 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Domain Name Industry Newsletter
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 06-20-2008, 09:23 AM   · #1
-Ray-
An American Soldier
 
-Ray-'s Avatar
 
Name: Ray
Location: Pennsylvania
Trader Rating: (25)
Join Date: Jun 2005
Posts: 1,521
NP$: 347.25 (Donate)
-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold
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)"


Please register or log-in into NamePros to hide ads
__________________
-- Afghanistan --

Last edited by -Ray- : 06-20-2008 at 10:07 AM.
-Ray- is offline   Reply With Quote
Old 06-20-2008, 09:33 AM   · #2
-NC-
Traveller
 
-NC-'s Avatar
 
Location: In an airport, probably
Trader Rating: (35)
Join Date: Mar 2007
Posts: 1,347
NP$: 573.28 (Donate)
-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of
Animal Cruelty Animal Rescue Ethan Allen Fund Protect Our Planet
select title where LEFT(title,1) = $yourletter

http://dev.mysql.com/doc/refman/5.0...l#function_left

-NC- is online now  
  Reply With Quote
Old 06-20-2008, 09:38 AM   · #3
-Ray-
An American Soldier
 
-Ray-'s Avatar
 
Name: Ray
Location: Pennsylvania
Trader Rating: (25)
Join Date: Jun 2005
Posts: 1,521
NP$: 347.25 (Donate)
-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold
thanks.. ill try that...
__________________
-- Afghanistan --
-Ray- is offline   Reply With Quote
Old 06-20-2008, 09:41 AM   · #4
-NC-
Traveller
 
-NC-'s Avatar
 
Location: In an airport, probably
Trader Rating: (35)
Join Date: Mar 2007
Posts: 1,347
NP$: 573.28 (Donate)
-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of
Animal Cruelty Animal Rescue Ethan Allen Fund Protect Our Planet
no problem, glad it worked, you could also use

where title LIKE '$yourletter%'
http://dev.mysql.com/doc/refman/5.0...-functions.html

not sure which one is more efficient...

edit: hey! you edited your post, did it not work after all?
-NC- is online now  
  Reply With Quote
Old 06-20-2008, 09:48 AM   · #5
-Ray-
An American Soldier
 
-Ray-'s Avatar
 
Name: Ray
Location: Pennsylvania
Trader Rating: (25)
Join Date: Jun 2005
Posts: 1,521
NP$: 347.25 (Donate)
-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold
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.
-Ray- is offline   Reply With Quote
Reply

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
free webhosting Find out how! Buy Flash Arcade Game Script
Advertise your business at NamePros
All times are GMT -7. The time now is 09:29 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0