illuz1on Posted May 24, 2007 Share Posted May 24, 2007 Anyone know how I would fix this little piece of code? Thanks echo '<option value=\"viewguide.php?id='.$record['id'].'\">'.$record['name'].'</option>'; Quote Link to comment https://forums.phpfreaks.com/topic/52737-piece-of-code-need-help-with-please/ Share on other sites More sharing options...
TEENFRONT Posted May 24, 2007 Share Posted May 24, 2007 please explain what its not doing... im guessing its not showing the id and name? stick the echo in " " instead of ' ', should sort it? Quote Link to comment https://forums.phpfreaks.com/topic/52737-piece-of-code-need-help-with-please/#findComment-260394 Share on other sites More sharing options...
B34ST Posted May 24, 2007 Share Posted May 24, 2007 or remove the backslashes before the quotation marks: echo '<option value="viewguide.php?id='.$record['id'].'">'.$record['name'].'</option>'; Quote Link to comment https://forums.phpfreaks.com/topic/52737-piece-of-code-need-help-with-please/#findComment-260402 Share on other sites More sharing options...
marcus Posted May 24, 2007 Share Posted May 24, 2007 Just do: echo "<option value=\"viewguide.php?id=$record[id]\">$record[name]</option>\n"; Quote Link to comment https://forums.phpfreaks.com/topic/52737-piece-of-code-need-help-with-please/#findComment-260403 Share on other sites More sharing options...
Barand Posted May 24, 2007 Share Posted May 24, 2007 But because you haven't quoted the index strings it now assumes id and name must be defined constants. So now it has to search the script for the constant definitions. Oh! it can't find them, so it now assumes they are strings with values 'id' and 'name'. You could've saved all that by quoting them in the first place. Quote Link to comment https://forums.phpfreaks.com/topic/52737-piece-of-code-need-help-with-please/#findComment-260416 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.