Hello, Im trying to replace a random statement in my html file with a function. HTML: <tr> <td align="right">Category: </td> <td>%{cat}%</td> </tr> HTML: function Category() { echo '<select name="category">'; $query = "SELECT * FROM {$db_prfix}multi_cat"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { if ($row['status'] == '1') { echo ' <option value=' . $row['id'] . '>' . $row['name'] . '</option> '; } } echo '</select>'; } $content_get = file_get_contents("multi_templates/signup.html"); $content = str_replace('%{cat}%',Category(),$content_get); echo $content; PHP: It's getting the drop down box... just randomly dumping it above everything else in the html... any ideas? Thanks
This should work: <?php function Category() { $return = '<select name="category">'; $query = "SELECT * FROM {$db_prfix}multi_cat"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { if ($row['status'] == '1') { $return .= ' <option value=' . $row['id'] . '>' . $row['name'] . '</option> '; } } return $return . '</select>'; } $content_get = file_get_contents("multi_templates/signup.html"); $content = str_replace('%{cat}%',Category(),$content_get); echo $content; ?> PHP: Rep appreciated (If it works for you, that is ) Jay
I fixed it. Don't know why but i just used the <td> in the function, not html. Strange but yeah. Thanks ^ BTW, You must spread some Reputation around before giving it to jayshah again.