I am dieing trying to figure this out for days! Searching is not helping. How do I use str_replace with an array. I have a list of results. I need the str_replace to go through each result as it is printed and change all the spaces with "+" symbols so they can be transfered through the url bar.
Here is what my code.
<?php
include("dbinfo.inc.php");
mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT model, COUNT(model) FROM table1 GROUP BY model";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo "<a href=search.php?var2=". $row['$model'] .">". $row['model'] ."</a> (". $row['COUNT(model)'] .")";
echo "<br>";
}
?>
Please help!
Quick question. please help
Moderator: General Moderators
-
SomeoneE1se
- Forum Newbie
- Posts: 20
- Joined: Sat May 31, 2008 2:53 am
Re: Quick question. please help
and
dosen't work?
Code: Select all
<?php
include("dbinfo.inc.php");
mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT model, COUNT(model) FROM table1 GROUP BY model";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo "<a href=search.php?var2=". str_replace(' ', '+', $row['$model']) .">". $row['model'] ."</a> (". $row['COUNT(model)'] .")";
echo "<br>";
}
?>