Results 1 to 1 of 1

Thread: mysqli dropdown

  1. #1
    Join Date
    May 2014
    Thanked 0 Times in 0 Posts

    Default mysqli dropdown

    I got one of those AHA moments. The following code
    is what I want in that it creates a menu and I can select and
    display a table row. I still need to use that selection to update
    the "lastused". I really appreciate your help.

    <!DOCTYPE><html><head><title>email menu</title></head>
    <form name="form" method="post" action="">
    //============== check connection
    {echo "Can't Connect to mySQL:".mysqli_connect_error();}
    {echo "Connected to mySQL</br>";}
    //This creates the drop down box
    echo "<select name= 'target'>";
    echo '<option value="">'.'--- Select email account ---'.'</option>';
    $query = mysqli_query($con,"SELECT target FROM emailtbl");
    $query_display = mysqli_query($con,"SELECT * FROM emailtbl");
    {echo "<option value='". $row['target']."'>".$row['target']
    echo '</select>';
    <input type="submit" name="submit" value="Submit"/><!-- update "lastused" using selected "target"-->

    <!DOCTYPE><html><head><title>email menu</title></head>
    {echo "Can't Connect to mySQL:".mysqli_connect_error();}
    $name = $_POST['target'];
    $fetch="SELECT target,username,password,emailused,lastused, purpose, saved FROM emailtbl WHERE target = '".$name."'";
    $result = mysqli_query($con,$fetch);
    {echo "Error:".(mysqli_error($con));}
    $lastused = "CURDATE()"; // update "lastused" using selected "target"
    //display the table
    echo '<table border="1">'.'<tr>'.'<td bgcolor="#ccffff align="center">'. 'Email menu'. '</td>'.'</tr>';
    echo '<tr>'.'<td>'.'<table border="1">'.'<tr>'.'<td bgcolor="#ccffff align="center">'.'target'.'</td>'.'<td bgcolor="#ccffff align="center">'.'username'.'</td>'.'<td bgcolor="#ccffff align="center">'.'password'.'</td>'.'<td bgcolor="#ccffff align="center">'.'emailused'.'</td>'.'<td bgcolor="#ccffff align="center">'.'lastused'.'</td>'.'<td bgcolor="#ccffff align="center">'.'purpose'. '</td>'.'<td bgcolor="#ccffff align="center">'. 'saved' .'</td>'.'</tr>';
    {echo ("<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td>$data[3]</td><td>$data[4]</td><td>$data[5]</td><td>$data[6]</td></tr>");}
    echo '</table>'.'</td>'.'</tr>'.'</table>';
    Last edited by 12Strings; 06-07-2014 at 02:54 AM.

Similar Threads

  1. mysqli dropdown
    By 12Strings in forum PHP
    Replies: 2
    Last Post: 06-02-2014, 04:35 PM
  2. Resolved mysql and mysqli connect
    By Deadweight in forum MySQL and other databases
    Replies: 1
    Last Post: 05-11-2014, 04:39 PM
  3. MySQLi and the PHP5.4 breaking changes.
    By ApacheTech in forum PHP
    Replies: 1
    Last Post: 07-28-2012, 04:30 PM
  4. Change syntax from mysqli to mysql
    By newphpcoder in forum PHP
    Replies: 0
    Last Post: 10-27-2011, 08:34 AM
  5. Mysqli vs Mysql and CMS
    By Victro in forum MySQL and other databases
    Replies: 2
    Last Post: 06-16-2010, 01:14 PM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts