Re: Can a range be passed to a query?(RESOLVED)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2009-08-03 at 09:33 -0700, Miller, Terion wrote:

> Here is is incase anyone else ever needs it.
> 
>                                        //Create array with letters AND number sign                        $letters = range('A','Z');                        array_push($letters, 'nums');                                                $menu = '';                        $selectedLetter = isset($_GET['letter']) ? $_GET['letter'] : null;                        foreach($letters as $letter)                        {                            if($letter == $selectedLetter && $selectedLetter != 'nums')                            {                                $menu .= sprintf('%s&nbsp', $letter);                            }                            else if($letter == $selectedLetter && $selectedLetter == 'nums')                            {                                $menu .= sprintf('%s&nbsp', '#');                            }                            else                            {                                if($letter == 'nums')                                {                                    $menu .= sprintf('<a href="browse.php?letter=%s">%s</a>&nbsp;', 'nums', '#');                                }                                else                                {                                    $menu .= sprintf('<a href="browse.php?letter=%s">%s</a>&nbsp;', $letter, $letter);                                }                            }                                                      }                        echo "<div align=\"center\"><b>{$menu}</b><br /></div>";                                                                                                                                                                                                                                                              //Show all restaurants that start with $letter  not between "A" and "Z"                        if ($selectedLetter == "nums")                        {                            for($i = 0; $i <= 9; $i++)                            {                                $sql = "SELECT DISTINCT ID, name, address FROM restaurants WHERE name LIKE '$i%'";                                                                                                $result = mysql_query($sql) or die(mysql_error());                                                            while($row = mysql_fetch_assoc($result))                                {                                    $name = $row['name'];                                     printf('<a href="view.php?ID=%s"><b>%s</b><br />%s<br /><br /></a>', $row['ID'], $row['name'], $row['address']);                                                                    }                                                }                                                                    }                        else                        {                             $sql = "SELECT DISTINCT ID, name, address FROM restaurants WHERE name LIKE '$selectedLetter%'";                                                        $result = mysql_query($sql) or die(mysql_error());                                                        while($row = mysql_fetch_assoc($result))                            {                                $name = $row['name'];                                 printf('<a href="view.php?ID=%s"><b>%s</b><br />%s<br /><br /></a>', $row['ID'], $row['name'], $row['address']);                                                            }                                                      }
> 
> On 8/3/09 10:12 AM, "Miller, Terion" <tmiller@xxxxxxxxxxxxxxxxxxxx> wrote:
> 
> 
> 
> 
> On 8/3/09 9:46 AM, "sono-io@xxxxxxxxxxxxx" <sono-io@xxxxxxxxxxxxx> wrote:
> 
> 
> 
> On Aug 3, 2009, at 7:19 AM, Miller, Terion wrote:
> 
> > Not sure why none of these are working for me since you have them
> > tested against your table....I get this error...
> 
>         Hopefully I'm not speaking out of turn here, but did you by any
> chance copy and paste that code from an e-mail?  If so, there may be
> invisible characters masquerading as spaces.  I use TextWrangler (on a
> Mac) and choose "Zap Gremlins..." so they show and then delete them.
> That usually solves the problem for me.
> 
> Frank
> 
> 
> Thanks Frank, but yep I'm using an editor that is good about such things, I'm not sure what the problem can be. And I get all the way to noon to figure it out.
> 
> 

Just for the future, are you able to format your emails as pure text
before you send them, as they get real mangled by the time they reach us
otherwise! :p

Thanks,
Ash
http://www.ashleysheridan.co.uk

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux