| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Regular Join Date: Jan 2006
Posts: 238
![]() ![]() ![]() | Displaying Stuff With MySQL - Please Help Ok so here's the code: Code: <?php
// The MySQL info, edit these
$host = "myhost"; // the database location. if you dont know it, leave it as it is
$dbuser = "myuser"; // the database username
$dbpass = "mypass"; // the databases user's pass
$dbname = "voting"; // the name of the database
// The actual connection. DO NOT EDIT THESE
mysql_connect("$host","$dbuser","$dbpass"); // Using the variables stated above
$display = ("SELECT challenger FROM battle");
echo $display;
?> ????: NamePros.com http://www.namepros.com/programming/197174-displaying-stuff-with-mysql-please-help.html I'm quite new to MySQL so I dont know what to do. |
| |
| | #3 (permalink) |
| NamePros Member Join Date: Apr 2006 Location: Central PA
Posts: 101
![]() | theres more efficient ways to do it, but you can try this. Code: mysql_connect("$host","$dbuser","$dbpass");
mysql_select_db($dbname);
$display = "SELECT challenger FROM battle";
$result = mysql_query($display) or die(mysql_error());
while($row = mysql_fetch_assoc($result))
{
$stuff = $row['challenger'];
echo $stuff;
} |
| |
| | #4 (permalink) |
![]() Join Date: Jul 2005 Location: Coffs H, Australia
Posts: 3,456
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Furthering what NonProphet said: Your code Swefx, simply echos a MySQL query, but first you need to run that query by MySQL, then MySQL will send back data from that query, in the form of an array (or a few other choices). NonProphet's code should work fine
__________________ Free Forums / GoDaddy Coupon Codes (NEW DOMAIN!) / Free Arcade Script / <?='Your computer is '.(1?fine:broken).'.'?> |
| |
| | #5 (permalink) | ||||
| Soon to be RICHdoggie! Join Date: Jan 2005 Location: UK
Posts: 2,408
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
You could do this with what you have: PHP Code: | ||||
| |