dennismonsewicz Posted August 19, 2008 Share Posted August 19, 2008 Is there a way to manipulate a query to strip numbers out of a mysql query? Here is some example code I have written: $result = mysql_query("SELECT * FROM test") or die(mysql_error()); $i = 0; $notallowed = "1234567890"; while($i < mysql_num_fields($result)) { $meta = mysql_fetch_field(str_replace($notallowed, "", $result),$i); echo $i . ". " . $meta->name . "<br />"; $i++; } Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted August 19, 2008 Author Share Posted August 19, 2008 BUMP Quote Link to comment Share on other sites More sharing options...
Mchl Posted August 19, 2008 Share Posted August 19, 2008 Don't quite understand what you're doing, byt $notallowed has to be an array $notallowed = array("0","1","2","3","4","5","6","7","8","9"); And $result is not a string, so you cannot use str_replace on it... Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted August 19, 2008 Author Share Posted August 19, 2008 I thought it had to be an array... I am displaying column names in my sql table but some of the columns contain numbers, IE(Name1, Name2). I am wanting to strip out the 1, 2, 3, 4... or whatever number it happens to be. Quote Link to comment Share on other sites More sharing options...
Mchl Posted August 19, 2008 Share Posted August 19, 2008 I'm pretty sure you shouldn't have table like that... echo $i . ". " . str_replace($notallowed,"",$meta->name) . "<br />"; Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted August 19, 2008 Author Share Posted August 19, 2008 I know its a retarded way of setting up it the table but its the only solution I can come up with for the project I am working on. Thanks for the help, the script worked like a charm Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.