is it possible to add white spaces in strings, like for instance if i have this string "abcdefghi", and add white spaces to have this "abc def ghi" ?
thanks in advance
Moderator: General Moderators
i have this piece of code ...dajawu wrote:That one made me laugh, thanks! But seriously if your trying to put more then one space in a PHP string or HTML you should use
Code: Select all
$query = "SELECT * FROM `tbl` WHERE `field1`='$something''";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$query = "SELECT * FROM `tbl2` WHERE `field2`=".$row['value'];
(...)
}
Code: Select all
$a = substr($row['value'], 0, 3);
$b = substr($row['value'], 3, 3);
$c = substr($row['value'], 6, 3);
$value = $a." ".$b." ".$c;
Completely off topic here, but as a general rule you shouldn't ever need to do a select query while you're looping through the results of another select. I can see that you could replace your code there with a join...bouncer wrote:Code: Select all
$query = "SELECT * FROM `tbl` WHERE `field1`='$something''"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $query = "SELECT * FROM `tbl2` WHERE `field2`=".$row['value']; (...) }
Code: Select all
$query = "SELECT * FROM `tbl` RIGHT JOIN `tbl2` ON `tbl`.`value` = `tbl2`.`field2` WHERE `field1`='$something''";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
//stuff
}