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 Sat Feb 24, 2024 8:06 pm

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: onclick use
PostPosted: Sun Sep 11, 2022 2:09 pm 

Joined: Tue Jun 16, 2015 1:03 am
Posts: 21
Hi, the code below displays the records in a database table. I select a record from a dropdown and
update a couple of fields in that record. So far so good.... Then I want to, using the "target"
field (which is a url) as an argument, onclick or whatever and go to that url. Surely there's a way?

<!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 lookuptbl");
$query_display = mysqli_query($con,"SELECT * FROM lookuptbl");
{echo "<option value='". $row['target']."'>".$row['target']
echo '</select>';

<input type="submit" name="submit" value="Submit"/>
{echo "Can't Connect to mySQL:".mysqli_connect_error();}
$name = $_POST['target'];
$fetch="SELECT id, target, username, password, purpose, emailused,lastused,
count FROM lookuptbl 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">'. 'lookup menu'. '</td>'.'</tr>';
echo '<tr>'.'<td>'.'<table border="1">'.'<tr>'.'
<td bgcolor="#CFB53B align="center">'.'id'.'</td>'.'
<td bgcolor="#CFB53B align="center">'.'target'.'</td>'.'
<td bgcolor="#ccffff align="center">'.'username'.'</td>'.'
<td bgcolor="#ccffff align="center">'.'password'.'</td>'.'
<td bgcolor="#ccffff align="center">'.'purpose'. '</td>'.'
<td bgcolor="#ccffff align="center">'.'emailused'.'</td>'.'
<td bgcolor="#CFB53B align="center">'.'lastused'.'</td>'.'
<td bgcolor="#CFB53B align="center">'.'count'. '</td>'.'</tr>';
{echo ("<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td>$data[3]</td>
echo '</table>'.'</td>'.'</tr>'.'</table>';
$sql = "UPDATE lookuptbl SET lastused=NOW(), count=$count + 1 WHERE target=$target";
if ($con->query($sql) === TRUE) { echo "Record updated successfully"; }
else { echo "Error updating record: " . $con->error; }
// $con->close();

<button onclick="myFunction('<?php echo $row["url"];?>')">go to url</button>
<script language="javascript">
var sid;
function myFunction(sid) {;

 Post subject: Re: onclick use
PostPosted: Mon Sep 19, 2022 11:20 pm 

Joined: Tue Jun 16, 2015 1:03 am
Posts: 21
Am I to understand that no one here understands the PHP manuals enough to relate to your benefactors?

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 13 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