Getting results from MySQL
| From: | Anders Mellström | Date: | Fri, 21 Feb 2003 09:24:02 +0000 |
| Subject: | Getting results from MySQL | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-25816@lists.php.net to get a copy of this message | ||
I have a PHP<->MySQl-problem. I would be very greatful if anyone would help me.
I am - with the following code - trying to get results from a database. The problem isn't
recieving the results, it's where i get the results. All the information is placed far down on
the site, not in top.
If you're having problems understanding what I'm trying to say, I don't blame you. I
don't really understand either. The easiest thing would be for you to check the code, then got
to the site link below to see for yourselves.
Thanks
//Anders
link: http://medlem.spray.se/tippafotboll/full.php
code:
<?php
if (!($dblink = mysql_connect("localhost", "*****", "*****")))
//Databaskoppling mot server.
{
print("Kunde inte skapa koppling mot databasen.");
}
if (!(mysql_select_db("tippafotboll_se_db", $dblink)))
{
print("Kunde inte välja databasen.");
}
else
{
//Array
$getarray = mysql_db_query("tippafotboll_se_db", "SELECT * FROM tblTeams");
while($arrayrow = mysql_fetch_array($getarray))
{
$team[$arrayrow["id"]] = $arrayrow["teamname"];
}
print("<html><head></head><body>");
print("<table width='50%' border='1'>\n");
print("<form name='newbet' method='post'
action='insertbet.php'>\n");
//SQL-query
$row = mysql_db_query("tippafotboll_se_db", "SELECT * FROM tblGames ORDER BY
date");
while($games = mysql_fetch_object($row))
{
$hid = $games->home;
$aid = $games->away;
$gameid = $games->id;
print("<tr><td> $team[$hid] - $team[$aid]
</td>\n");
print("<td><input type='radio' name='game$gameid'
value='1'> </td>\n");
print("<td><input type='radio' name='game$gameid'
value='x'> </td>\n");
print("<td><input type='radio' name='game$gameid'
value='2'></td><br></tr>\n");
}
print("<tr><td><input type='submit' value='skicka in
rad'></form></tr></table></body></html>\n");
}
//Databaskopplingen stängs
mysql_close();
?>