Re: PHP syntax

From: Date: Thu, 01 May 2003 12:19:28 +0000
Subject: Re: PHP syntax
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-145932@lists.php.net to get a copy of this message
I want to be able to use the str_replace function so that I do not have spaces and replace them with underscores. "Chris Hayes" <chayes@antenna.nl> wrote in message news:5.2.0.9.0.20030501131245.020cdb60@pop4.antenna.nl... > At 12:59 1-5-03, you wrote: > >What I would like to do is use what Luke or Burhan gave me to try as far as > >replacing the spaces with an underscore, but I am having a hard time placing > >the variable for me to manipulate! > > I hope I get your question right: Am i right that the replacing of the > space to an underscore works now? > > >Overall all result will be 3 columns with different record fields represnted > >by a bar code with spaces taken out. > So your question is how to present the results in 3 columns? > > simplest would be: > echo '<tr>'; > for($i = 0; $i < $numofrows; $i++) { > $row = mysql_fetch_array($result); //get a row from our result set > echo > "<TD><etc>".$row['Bldgroomcab']."</TD>\n"; > //make new row after every 3rd item > if (($i+1)%3==0) echo "</TR>\n<tr>"; > } > echo '</tr>'; > > > > About your query: if you are only using the field Bldgroomcab, you can > replace the * in the query with Bldgroomcab, without quotes, to reduce the > result set. > > > > >I have been looking at this for several hours now and I am still scrathcing > >my head. Any suggestions? > > > >for($i = 0; $i < $numofrows; $i++) { > > $row = mysql_fetch_array($result); //get a row from our result set > > > > //$Bldgroomcabpost = ".$row['Bldgroomcab']."; > > //$Bldgroomcabspace = str_replace(" ", "_", $Bldgroomcabpost); > > echo "<TD><font size=3 > > >>face=********><center>".$row['Bldgroomcab']."</TD>\n"; > > echo "</TR>\n"; > >} > >//now let's close the table and be done with it > >echo "</TABLE>\n"; > >echo "</body>" > > > >?> > > > > > > > >-- > >PHP General Mailing List (http://www.php.net/) > >To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#145932) next »