[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 06-20-2008, 09:23 AM   #1 (permalink)
An American Soldier
 
-Ray-'s Avatar
 
Join Date: Jun 2005
Location: Pennsylvania
Posts: 1,630
2.53 NP$ (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-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)"
__________________
Completely Free cPanel Hosting
-- Deployed to Afghanistan --
"There is no such thing as rich over-night unless you owned Google stock in 2006"

Last edited by -Ray-; 06-20-2008 at 10:07 AM.
-Ray- is offline  
Old 06-20-2008, 09:33 AM   #2 (permalink)
Traveller
 
-NC-'s Avatar
 
Join Date: Mar 2007
Location: Yet another city
Posts: 1,392
614.57 NP$ (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/...#function_left

-NC- is offline  
Old 06-20-2008, 09:38 AM   #3 (permalink)
An American Soldier
 
-Ray-'s Avatar
 
Join Date: Jun 2005
Location: Pennsylvania
Posts: 1,630
2.53 NP$ (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-Ray- is a splendid one to behold


thanks.. ill try that...
__________________
Completely Free cPanel Hosting
-- Deployed to Afghanistan --
"There is no such thing as rich over-night unless you owned Google stock in 2006"
-Ray- is offline  
Old 06-20-2008, 09:41 AM   #4 (permalink)
Traveller
 
-NC-'s Avatar
 
Join Date: Mar 2007
Location: Yet another city
Posts: 1,392
614.57 NP$ (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 offline  
Old 06-20-2008, 09:48 AM   #5 (permalink)
An American Soldier
 
-Ray-'s Avatar
 
Join Date: Jun 2005
Location: Pennsylvania
Posts: 1,630
2.53 NP$ (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-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>");

}
?>
__________________
Completely Free cPanel Hosting
-- Deployed to Afghanistan --
"There is no such thing as rich over-night unless you owned Google stock in 2006"

Last edited by -Ray-; 06-20-2008 at 10:06 AM.
-Ray- is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 11:17 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85