Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ddefelicis

    (@ddefelicis)

    Thank you for your patience, I’m a beginner.

    The plugin activated is “allow php code in posts and pages”.

    I’d like to fill a listbox with database and I wrote the following code that works without problem in a php file loaded as page template but edited inside the WP page I obtain an empty listbox because (according to me) the html code after echo it’s not considered.

    <form action=’processform.php’ method=’POST’>
    <select name=’Category’>
    [php]
    $Conn = mysql_connect(“localhost”, “root”, “”);
    if (!$Conn)
    {
    die(‘Could not connect: ‘ . mysql_error());
    }
    mysql_select_db(“dati”,$Conn);
    $query = “SELECT Category FROM Dati.prodotti”;
    $result=mysql_query($query,$Conn);
    $row = mysqli_fetch_assoc($result);
    while ($row = mysql_fetch_assoc($result))
    {
    echo “<option value=”.$row[‘Category’].”>”.$row[‘Category’].”</option>”;
    }
    [/php]
    </SELECT>
    </form>

    Thread Starter ddefelicis

    (@ddefelicis)

    Sorry I’ve previously semplified too much my problem:

    I want to fill a listbox with mySQL data in a WP page (I’m writing an HTML form data INPUT) and I need to use PHP.
    I’ve activated the plugin “Allow PHP in Posts and Pages”.

    To fill my listbox I used this code (copied by PHP manual):

    <form action=’processform.php’ method=’POST’>
    [php]


    <select name=’petType’>\n”;
    while ($row = mysqli_fetch_assoc($result))
    {
    extract($row);
    echo “<option value=’$petType’>$petType\n”;
    }
    echo “</select>\n”;


    [/php]

    the statements ” echo “<option value=’$petType’>$petType\n”; “

    it’s not considered by WP when I update the page.

    Thread Starter ddefelicis

    (@ddefelicis)

    Yes i’ve made what you suggest as you can see in my original question but in a wordpress page the HTML code after the < tag is erased.

    E.g.
    [php]
    Echo “<hello word>”;
    [\php]

    Produce nothing

Viewing 3 replies - 1 through 3 (of 3 total)