MySQL Forums
Forum List  »  PHP

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

Place "/" before "n" -- just screws up the output. I can get the target, but this thing looks like crap.

https://database39.com/dropdownworking.php

I have to say, I have been doing this since 1967 (I'm 82), taught over 3,000 professional programmers and this is the nastiest piece of code I have ever seen. What kills me are the random sequences of special characters and I find it hard to believe that this can't be done with simpler, more straight-ahead code.

I really, really hate to bother you with this petty crap and I always spend at least a day or two googling on something before I come to you. Do you have a PayPal account?

<form>

<?php
// Database connection data
$servername = "mysql503.discountasp.net";
$dbuser = "parker1939";
$dbpasswrd = "xxxxxxx";
$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>

Options: ReplyQuote


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


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.