Jump to content

Display mysql result in a drop down box


skatermike21988

Recommended Posts

Hi guys i am workin on a script that includes gd, and the user can change their font and text displayed on their profile contact, well i am wanting to be able to insert the font names into mysql and have it displayed in a drop down box, this way when i add new fonts i don't have to go and edit my whole script.

I would also like for when a font is selected it will load the page that parses the gd next to the drop down and display's a preview.

ALL HELP APPRECIATED
Link to comment
Share on other sites

Try this:
[code]<?php
echo "<select name='font'>";
$result = mysql_query("SELECT `font_name` FROM `fonts`");
while($row = mysql_fetch_assoc($result)) {
    echo "<option value='$row[font_name]'>$row[font_name]</option>";
}
echo "</select>";
?>[/code]
Link to comment
Share on other sites

try redoing this line to look like this then....that's the only last thing I can think of
[code]echo "<option value='" . $row['font_name'] . "'>" . $row['font_name'] . "</option>";
[/code]
or

[code]echo "<option value='{$row['font_name']}'>{$row['font_name']}</option>";[/code]

both are the exact same thing....just depends on how YOU want it to look.....code-wise
they only real significant change I did though was to add quotes to your key
[quote]$row[[size=12pt][color=red]'[/color][/size]font_name[size=12pt][color=red]'[/color][/size]][/quote]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.