Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 983 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

163-My Row Title.html to 163-my-row-title.html

Thread title: 163-My Row Title.html to 163-my-row-title.html
Closed Thread    
    Thread tools Search this thread Display Modes  
01-10-2007, 06:07 PM
#1
Dan is offline Dan
Dan's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 3,164
iTrader: 15 / 86%
 

Dan is an unknown quantity at this point

  Old  163-My Row Title.html to 163-my-row-title.html

PHP Code:
                     <?php

                        $rowcolor 
1;

                        
$sql "select wallpaperid, title from wallpaper where status = 'L' order by downloads desc limit 0,10";

                        
$result mysql_query($sql ,$db);

                        if (
$myrow mysql_fetch_array($result)) {

                           do {

                              if (
$rowcolor == 1) {
                                 
$rowcolorhex "light";
                                 
$rowcolor 0;
                              } else {
                                 
$rowcolorhex "dark";
                                 
$rowcolor 1;
                              }

                              
printf("<li class=%s><a href=http://domain.com/%s-%s.html>%s</a> "$rowcolorhex$myrow["wallpaperid"], $myrow["title"], $myrow["title"]);

                           } while (
$myrow mysql_fetch_array($result));

                        }
                     
?>
This outputs:
Code:
<li><a href="http://domain.com/163-My Row Title.html">My Row Title
The problem is, I need it outputted like:
Code:
<li><a href="http://domain.com/163-my-row-title.html">My Row Title
163-My Row Title.html to 163-my-row-title.html

Don't suppose someone could help me out?

01-10-2007, 06:11 PM
#2
Cooleo is offline Cooleo
Status: Member
Join date: Sep 2005
Location: Stoke, UK
Expertise:
Software:
 
Posts: 151
iTrader: 0 / 0%
 

Cooleo is on a distinguished road

Send a message via MSN to Cooleo

  Old

$nodash=str_replace(' ','-',$myrow["title"]);
$tolower=strtolower($nodash);
printf("<li class=%s><a href=http://domain.com/%s-%s.html>%s</a> ", $rowcolorhex, $myrow["wallpaperid"], $tolower, $myrow["title"]);

01-10-2007, 06:28 PM
#3
Dan is offline Dan
Dan's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 3,164
iTrader: 15 / 86%
 

Dan is an unknown quantity at this point

  Old

Thanks Cooleo, worked like a charm.

01-10-2007, 06:38 PM
#4
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

You could also lose the variables and do the replacement within the printf call. I just don't like creating variables to be used only once.

PHP Code:
printf('<li class="%s"><a href="http://domain.com/%s-%s.html">%s</a></li>',
        
$rowcolorhex,
        
$myrow['wallpaperid'],
        
strtolower(str_replace(' ''-'$myrow['title'])),
        
$myrow['title']); 

01-10-2007, 09:06 PM
#5
Cooleo is offline Cooleo
Status: Member
Join date: Sep 2005
Location: Stoke, UK
Expertise:
Software:
 
Posts: 151
iTrader: 0 / 0%
 

Cooleo is on a distinguished road

Send a message via MSN to Cooleo

  Old

Yeah i was doing it just to show him each process.

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed