Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[PHP] A drop down menu with MySQL data?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Localhost
I post too much
Reputation: 0

Joined: 28 Apr 2007
Posts: 3402

PostPosted: Sat May 10, 2008 10:21 am    Post subject: [PHP] A drop down menu with MySQL data? Reply with quote

Okay... so i need to make this

Code:
 echo "Send to: <br><input type='text' name='to'>";


To be changed into a drop menu... and the information in the drop down menu would be information from
database: log
table: usr

Thanks Smile

_________________
Back to top
View user's profile Send private message MSN Messenger
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Sat May 10, 2008 10:39 am    Post subject: Reply with quote

Code:
<html>
<select name="top5">
<?php
$res = mysql_query("SELECT name FROM user ORDER BY name ASC");

if(mysql_num_rows($res)){
   while($row = mysql_fetch_assoc($res)) {
        ?>
      <option><?php echo $row['name']; ?></option>
      <?php
    }
}
?>

</select>
</html>


(The field name of what you need in name here. And it arrangs it in alphabetical order)
Back to top
View user's profile Send private message
Localhost
I post too much
Reputation: 0

Joined: 28 Apr 2007
Posts: 3402

PostPosted: Sat May 10, 2008 11:24 am    Post subject: Reply with quote

Okay thanks. That works, but how will that effect me getting what they selected via the POST method

Code:
 $sendto = trim(mysql_real_escape_string($_POST["to"]));


This is wat i have so far

Code:
<html>
<select>
<?php

$con = mysql_connect("localhost","3434","45345");

mysql_select_db("login", $con);

$result = mysql_query("SELECT * FROM users", $con);


while($row = mysql_fetch_array($result))
{
  ?>

 Send to: <option><?php echo $row['username']; ?></option>
  <?php
    }
?>
<form action="send.php" method="POST">
<br>
Subject: <br><input type="text" name="sub">
<br>
Your Message: <br><textarea name="msg" rows="10" cols="45"></textarea><br>
<input type="submit" value="Send">
</form>
<?php
echo "<br>Back To [<a href=\"main.php\">Main</a>]<br><br/>";
?>
</select>
</html>


Below is a picture of what is showing up

For some reason, ¨Subject¨ is not showing up, drop down menu doesnt have a value, but besides that its what i want Smile

_________________
Back to top
View user's profile Send private message MSN Messenger
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Sat May 10, 2008 11:55 am    Post subject: Reply with quote

Do the select-menu in your form and give it a name.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites