CodeLobster IDE

Free cross-platform PHP IDE (HTML, PHP, CSS, JavaScript, Python code editor) with support Drupal, Joomla, Twig, JQuery, BackboneJS, LaravelJS, Node.js, CodeIgniter, CakePHP, Laravel, Magento, MeteorJS, Phalcon, Symfony, VueJS, WordPress, Yii
It is currently Mon Dec 02, 2024 7:11 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: trouble with MYSQLi dropdown
PostPosted: Fri Aug 19, 2016 1:09 am 
Offline

Joined: Tue Jun 16, 2015 1:03 am
Posts: 22
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]
--------------------------------------------------------


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2016 phpBB Group