/    Sign up×
Community /Pin to ProfileBookmark

Hi,

Anyone tell me why this is not appearing as an option dropdown?

Ta

Chris

[code=php]
<?php
// access the motors database;
$Host = “localhost”;
$User = “”;
$Password = “”;
$DBname = “”;
$connection = mysql_connect($Host,$User, $Password);
$Result = mysql_db_query($DBname,$Query,$connection);
//set up the query
$query = “select profiles.profilesid, profiles.secondname from profiles”;
//run the query
if(!$connection) { die(‘Eek’); }
$result = mysql_query($query, $connection) or die(mysql_error());
//The following lines return the results from the query and assign them to variables
while($row = mysql_fetch_array($result)){
$secondname = $row[‘secondname’];
$profilesid = $row[‘profilesid’];
//This line prints out the HTML Code with the returned data
echo “<option value=’$profilesid’>$secondname</option>”;
};
mysql_free_result($result);
?>
[/code]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceMar 03.2005 — Where's your HTML SELECT tags?
Copy linkTweet thisAlerts:
@chrisbauthorMar 03.2005 — Cheers - So

[code=php]

<?php
// access the motors database;
$Host = "localhost";
$User = "~######";
$Password = "#####";
$DBname = "######";
$connection = mysql_connect($Host,$User, $Password);
$Result = mysql_db_query($DBname,$Query,$connection);
//set up the query
$query = "select profiles.profilesid, profiles.secondname from profiles";
//run the query
if(!$connection) { die('Eek'); }
$result = mysql_query($query, $connection) or die(mysql_error());
//The following lines return the results from the query and assign them to variables
while($row = mysql_fetch_array($result)){
$secondname = $row['secondname'];
$profilesid = $row['profilesid'];
//This line prints out the HTML Code with the returned data
echo "<select name="dropdown">
echo "<option value='$profilesid'>$secondname</option>";
echo "</select>"
};
mysql_free_result($result);
?>
[/code]


Now -

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/sleaz/public_html/cms/test2.php on line 19

Tried adding and removing ; on line 19, but not working?
Copy linkTweet thisAlerts:
@phpnoviceMar 03.2005 — [code=php]
echo '<select name="dropdown">';
while($row = mysql_fetch_array($result)){
$secondname = $row['secondname'];
$profilesid = $row['profilesid'];
echo "<option value="{$profilesid}">{$secondname}</option>";
}
echo "</select>";
[/code]
Copy linkTweet thisAlerts:
@chrisbauthorMar 03.2005 — Thank you!!!? ? ? ? ?
Copy linkTweet thisAlerts:
@phpnoviceMar 03.2005 — Also:
[code=php]
echo '<select name="dropdown">';
while($row = mysql_fetch_array($result)){
echo "<option value="{$row['profilesid']}">{$row['secondname']}</option>";
}
echo "</select>";
[/code]
×

Success!

Help @chrisb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...