|
Answer» 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: [Select]<!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>";echodate('m/d/y');echo"</center>"; $con=mysqli_connect("localhost","root","cookie","homedb"); //----------------------checkconnection------------------------ if(mysqli_errno($con)) {echo"Can'tConnecttomySQL:".mysqli_connect_error();} else {echo"</br>";} $id='';$url='';$username='';$password='';$purpose=''; $emailused='';$date-time='';$count='';$saved='';
//----------Thiscreatesthedropdownboxusingrecordsinthetable----------- echo"<selectname='url'>"; echo'<optionvalue="">'.'---selectemailaccount---'.'</option>'; $query=mysqli_query($con,"SELECTurlFROMemailtbl"); $query_display=mysqli_query($con,"SELECT*FROMemailtbl"); while($ROW=mysqli_fetch_array($query)) {echo"<optionclass=highlightvalue='".$row['url']."'>".$row['url'] .'</option>';} echo'</select>'; ?> <input type="submit" name="submit" value="Submit"/> </form> { $url = $_POST['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($data = mysqli_fetch_row($fetch)) while($data=mysqli_fetch_row($result)) { 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><td>$data[7]</td> </tr>"); } echo '</table>'.'</td>'.'</tr>'.'</table>'; mysqli_query($con,"UPDATE emailtbl SET date-time = 'DATE()'; count = 'count + 1'; WHERE url=$url"); ?> </center></body></html> ------------------------------------------------------------------------ 2 Code: [Select]<?php echo"<center>";echodate('m/d/y');echo"</center>"; $con=mysqli_connect("localhost","root","cookie","homedb"); //----------------------checkconnection------------------------ if(mysqli_errno($con)) {echo"Can'tConnecttomySQL:".mysqli_connect_error();} else {echo"</br>";} $id='';$url='';$username='';$password='';$purpose=''; $emailused='';$date-time='';$count='';$saved='';
//----------Thiscreatesthedropdownboxusingrecordsinthetable----------- echo"<selectname='url'>"; echo'<optionvalue="">'.'---selectemailaccount---'.'</option>'; $query=mysqli_query($con,"SELECTurlFROMemailtbl"); $query_display=mysqli_query($con,"SELECT*FROMemailtbl"); while($row=mysqli_fetch_array($query)) {echo"<optionclass=highlightvalue='".$row['url']."'>".$row['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='".$row['url']."'>".$row['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($data = mysqli_fetch_row($fetch)) while($data=mysqli_fetch_row($result)) { 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><td>$data[7]</td> </tr>"); } echo '</table>'.'</td>'.'</tr>'.'</table>'; mysqli_query($con,"UPDATE emailtbl SET date-time = 'DATE()'; count = 'count + 1'; WHERE url=$url"); ?> </center></body></html>----------------------------------------------- 3 Code: [Select]<!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 $connect=mysql_connect("localhost","root","cookie")ordie("error"); mysql_select_db("homedb",$connect); $sql="SELECT*fromemailtbl"; $result=mysql_query($sql,$connect); $url='';; while($res=mysql_fetch_assoc($result)) { echo"<tr>"; echo"<td>";echo'<inputtype="RADIO"name="url">';echo"</td>"; echo"<td>";echo$res['username']>';echo"</td>"; echo"<td>";echo$res['password'];echo"</td>"; echo"<td>";echo$res['purpose'];echo"</td>"; echo"<td>";echo$res['emailused'];echo"</td>"; echo"<td>";echo$res['date-time'];echo"</td>"; echo"<td>";echo$res['count'];echo"</td>"; echo"<td>";echo$res['saved'];echo"</td>"; echo"</tr>"; } ?> </table> </form></body></html>--------------------------------------------------------
|