Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


link to url from button

  • Please log in to reply
1 reply to this topic

#1 12Strings


  • Members
  • 41 posts
  • Local time:06:31 PM

Posted 20 February 2017 - 07:42 PM

Hi, my code successfully creates a dropdown menu from a database and upon selecting a "target", displays the record in the form of a table including a radio button. My objective is to click the button to link to the "target". The "target" fields are
email addresses or URLs. Any pointers? Thanks in advance.

The code follows:

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

<!DOCTYPE><html><head><title>test menu display</title></head>

{echo "Can't Connect to mySQL:".mysqli_connect_error();}
$name = $_POST['target'];
$fetch="SELECT target, thingamajig FROM testbl WHERE target = '".$name."'";
$result = mysqli_query($con,$fetch);
{ echo "Error:".(mysqli_error($con)); }

//display the table
echo '<table border="1">'.'<tr>'.'<td bgcolor="#ccffff align="center">'. 'test menu'. '</td>'.'</tr>';
echo '<tr>'.'<td>'.'<table border="1">'.'<tr>'.'
<td bgcolor="#CFB53B align="center">'.'target'.'</td>'.'
<td bgcolor="#ccffff align="center">'.'thingamajig'.'</td>'.'
{ echo ("<tr><td>$data[0]</td><td>$data[1]</td></tr>"); }
echo '</table>'.'</td>'.'</tr>'.'</table>';


BC AdBot (Login to Remove)


#2 newage


  • Members
  • 21 posts

Posted 08 March 2017 - 07:25 AM

A few things to note. If that's all 1 script you don't need to re-declare $con. You're making the connection twice essentially. I usually make a functions.php file to declare my connections. Also, watch the asterisk (*). That can potentially use up more memory than what is really necessary in a shared web host environment.


Your issue is with the "mysqli_fetch_row()" function. You aren't using the $con. So it goes like this... "mysqli_fetch_row($con, $result)".

Edited by newage, 08 March 2017 - 07:52 AM.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users