CodeLobster IDE
http://codelobster.com/forum/

trouble with MYSQLi dropdown
http://codelobster.com/forum/viewtopic.php?f=3&t=12846
Page 1 of 1

Author:  12Strings [ Fri Aug 19, 2016 1:09 am ]
Post subject:  trouble with MYSQLi dropdown

Hi, I'm trying for awhile to code up a MYSQLi dropdown from a database, select a field(url, formatted as "http://www.thisurl.com) and arrive at that destination. I've tried several forums re. compatability (connection/query/output etc..Problem is I blow up at the first query (see screen shot). It's like my PHP isn't working. If someone will advise of the PHP issue maybe I can work out the app code. Any volunteers? Thanks!
--------------------------------------------------------------------- 1
Code:
<!DOCTYPE html><html>. 
<title>email visit info</title>
<head>
</head>
<BODY>
create and display dropdown from database, url selected provides needed username and password. clicking on selected takes the user(me) to that url<br>
<center>
<form id="testform" name="testform" action="" method="post" accept-charset="UTF-8">
     
<?php
echo "<center>";echo date('m/d/y');echo "</center>";
=mysqli_connect("localhost","root","cookie","homedb");
//---------------------- check connection ------------------------
    if(mysqli_errno())
    {echo "Can't Connect to mySQL:".mysqli_connect_error();}
    else
    {echo "</br>";}
  = '';   = '';  = '';  = '';
  = ''; -time = '';  = '';   = '';

// ----------This creates the drop down box using records in the table -----------
       echo "<select name= 'url'>";
    echo '<option value="">'.' ---select email account ---'.'</option>';
     = mysqli_query(,"SELECT url FROM emailtbl");
     = mysqli_query(,"SELECT * FROM emailtbl");
    while(=mysqli_fetch_array())
    { echo "<option class=highlight value='". ['url']."'>".['url']
    .'</option>';}
    echo '</select>';
    ?>
<input type="submit" name="submit" value="Submit"/>
    </form>
  {   
     = Array['url'];

// ----------------------- display the table ------------------------
    echo '<tr>'.'<td>'.'<table border="1">'.'<tr>'.'
<td bgcolor="#ccffff">'.'url'.'</td>'.'
<td bgcolor="#ccffff">'.'username'.'</td>'.'
<td bgcolor="#ccffff">'.'password'.'</td>'.'
<td bgcolor="#ccffff">'.'purpose'.'</td>'.'
<td bgcolor="#ccffff">'.'emailused'.'</td>'.'
<td bgcolor="#FFD47F">'.'date-time'.'</td>'.'
<td bgcolor="#FFD47F">'.'count'.'</td>'.'
<td bgcolor="#ccffff">'.'saved'.'</td>'.'</tr>';
    // while( = mysqli_fetch_row())
    while(=mysqli_fetch_row())
{
echo ("<tr>
<td>[0]</td><td>[1]</td><td>[2]</td>
<td>[3]</td><td>[4]</td><td>[5]</td>
<td>[6]</td><td>[7]</td>
</tr>");
}
    echo '</table>'.'</td>'.'</tr>'.'</table>';
mysqli_query(,"UPDATE emailtbl SET
date-time = 'DATE()'; count = 'count + 1';     
WHERE url=");
?> 
    </center></body></html>

[img]http://localhost/images/number1.png[img][/img][/img]

------------------------------------------------------------------------
2
Code:
<?php
echo "<center>";echo date('m/d/y');echo "</center>";
=mysqli_connect("localhost","root","cookie","homedb");
//---------------------- check connection ------------------------
    if(mysqli_errno())
    {echo "Can't Connect to mySQL:".mysqli_connect_error();}
    else
    {echo "</br>";}
  = ''; = '';  = '';  = '';  = '';
  = ''; -time = '';  = '';   = '';

// ----------This creates the drop down box using records in the table -----------
       echo "<select name= 'url'>";
    echo '<option value="">'.' ---select email account ---'.'</option>';
     = mysqli_query(,"SELECT url FROM emailtbl");
     = mysqli_query(,"SELECT * FROM emailtbl");
    while(=mysqli_fetch_array())
    { echo "<option class=highlight value='". ['url']."'>".['url']
    .'</option>';}
    echo '</select>';
    ?>
<input type="submit" name="submit" value="Submit"/>
    </form>
  {   

// ----------------------- display the table ------------------------
    echo '<tr>'.'<td>'.'<table border="1">'.'<tr>'.'

// ======================anchor attempt=========================
// echo "<a href='".['url']."'>".['url']."</a>";
// ==========================================================

<td bgcolor="#ccffff">'.'username'.'</td>'.'
<td bgcolor="#ccffff">'.'password'.'</td>'.'
<td bgcolor="#ccffff">'.'purpose'.'</td>'.'
<td bgcolor="#ccffff">'.'emailused'.'</td>'.'
<td bgcolor="#FFD47F">'.'date-time'.'</td>'.'
<td bgcolor="#FFD47F">'.'count'.'</td>'.'
<td bgcolor="#ccffff">'.'saved'.'</td>'.'</tr>';
    // while( = mysqli_fetch_row())
    while(=mysqli_fetch_row())
{
echo ("<tr>
<td>[0]</td><td>[1]</td><td>[2]</td>
<td>[3]</td><td>[4]</td><td>[5]</td>
<td>[6]</td><td>[7]</td>
</tr>");
}
    echo '</table>'.'</td>'.'</tr>'.'</table>';
mysqli_query(,"UPDATE emailtbl SET
date-time = 'DATE()'; count = 'count + 1';     
WHERE url=");
?> 
    </center></body></html>

[img]http://localhost/images/number2.png[img][/img][/img]
-----------------------------------------------
3
Code:
<!DOCTYPE html><html>
<head>
<title>test 3</title>
</head>
<body><center>
<form id="testform" name="testform" action="" method="post" accept-charset="UTF-8">

  <table border=1 cellpadding=2 cellspacing=2 bgcolor="#D4FFAA">
<tr>
    <th>url</th><th>username</th><th>password</th><th>purpose</th>
    <th>emailused</th><th>date-time</th><th>count</th><th>saved</th>
</tr>
<?php
=mysql_connect("localhost", "root", "cookie") or die("error");
mysql_select_db("homedb", );
="SELECT * from emailtbl";
=mysql_query(, );
='';;
while(=mysql_fetch_assoc())
{
echo "<tr>";
echo "<td>"; echo '<input type="radio" name="url" >'; echo "</td>";
echo "<td>"; echo ['username']>'; echo "</td>";
echo "<td>"; echo ['password']; echo "</td>";
echo "<td>"; echo ['purpose']; echo "</td>";
echo "<td>"; echo ['emailused']; echo "</td>";
echo "<td>"; echo ['date-time']; echo "</td>";
echo "<td>"; echo ['count']; echo "</td>";
echo "<td>"; echo ['saved']; echo "</td>";
echo "</tr>";
}
?>
  </table> </form></body></html>

[img]http://localhost/images/number3.png[img][/img][/img]
--------------------------------------------------------

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/