MySQL Forums
Forum List  »  PHP

Re: Table data into dropdown
Posted by: Parker Shannon
Date: March 29, 2022 06:18AM

Thank you, Peter.

I made 3 changes to this code:

conn = dbconnect
foo = short_name
footable - durham_person

Ran the code -- it does work -- but take a look at the result. How do I make those "n" characters go away?

Also, I don't know what "n" represents in the code.

Live script here: https://database39.com/testo.php

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script type='text/Javascript'>
function submit( f ) {
f.submit();
}
</script>
</head>
<body>
<form>

<?php
// Database connection data
$servername = "mysql503.discountasp.net";
$dbuser = "xxxxxxxxx";
$dbpasswrd = "xxxxxxxxx";
$dbname = "MYSQL5_1020784_database39";

// Create connection
$dbconnect = mysqli_connect($servername, $dbuser, $dbpasswrd, $dbname);

// Check connection
if (!$dbconnect) {
die("Connection failed: " . mysqli_connect_error());
}

$resfoo = mysqli_query( $dbconnect, "SELECT short_name FROM durham_person" ) or die( "Cannot retrieve foo values" );
echo "<b>Foo Value:</b>&nbsp;n";
echo " <select name='short_name' onChange='submit(this.form)'>n";
while( $row = mysqli_fetch_row( $resfoo )) {
$sel = ( $table === $row[0] ) ? "id='sel' selected" : "";
printf( " <option %s value='%s'>%s</option>n", $sel, $row[0], $row[0] );
}
echo " </select>n";
echo " <input id='edit' type='button' value='Pick a foo' onClick='submit(this.form)'>n";
?>

</form>
</body>
</html>

Options: ReplyQuote


Subject
Written By
Posted
March 28, 2022 06:58AM
Re: Table data into dropdown
March 29, 2022 06:18AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.