MYSQL table retrieval
Posted: Sat Jul 30, 2005 2:26 pm
[color=\"green\"]well ive been working on this for a while, and im not getting anywhere with it..i think its unfair on ada to make her wait any longer, so im throwing it open to the rest of the community...
note: im not, by a long shot..very good with mysql yet
/blum.gif\' class=\'bbc_emoticon\' alt=\':P\' />
i have a database, \"cards\" ..which has a four column table in it (ID, image, title, desc)
i am trying to pick a random number (1-156) and the print out the information in the corresponding row onto a php page
i think thats explain clearly enough
/blum.gif\' class=\'bbc_emoticon\' alt=\':P\' /> here\'s the code (if it is commented out, it simply means that its there for when i get the scrips drawing two cards)
[code]<?php
$carda = rand(1,156);
//$cardb = rand(1,156);
$link1 = mysql_query("SELECT * FROM `image` WHERE `cardid` = \'$carda\'") or die (mysql_error());
//$link2 = mysql_query("SELECT * FROM `image` WHERE `cardid` = \'$cardb\'") or die (mysql_error());
$name1 = mysql_query("SELECT * FROM `title` WHERE `cardid` = \'$carda\'") or die (mysql_error());
//$name2 = mysql_query("SELECT * FROM `title` WHERE `cardid` = \'$cardb\'") or die (mysql_error());
$desc1 = mysql_query("SELECT * FROM `desc` WHERE `cardid` = \'$carda\'") or die (mysql_error());
//$desc2 = mysql_query("SELECT * FROM `desc` WHERE `cardid` = \'$cardb\'") or die (mysql_error());
$cardid = $row["cardid"];
echo "<center><table width=\'80%\' border=\'0\' cellpadding=\'5\'>";
echo "<tr>";
echo "<td><img src=\' . $link1 . \' alt=\' . $name1 . \'></td>";
echo "$name1";
echo "<td><center>$card2n</center></td>";
echo "</tr>";
echo "</table>";
echo "<table width=\'60%\' border=\'0\'>";
echo "<tr>";
echo "<td><center><b>Interpretation</b>:";
echo "$desc1 </center></td>";
//echo " $card2d";
echo "</tr>";
echo "</table>";
echo "</center>";
?>[/code]
any/all help is appreciated
/smile.gif\' class=\'bbc_emoticon\' alt=\':)\' />[/color]
note: im not, by a long shot..very good with mysql yet
i have a database, \"cards\" ..which has a four column table in it (ID, image, title, desc)
i am trying to pick a random number (1-156) and the print out the information in the corresponding row onto a php page
i think thats explain clearly enough
[code]<?php
$carda = rand(1,156);
//$cardb = rand(1,156);
$link1 = mysql_query("SELECT * FROM `image` WHERE `cardid` = \'$carda\'") or die (mysql_error());
//$link2 = mysql_query("SELECT * FROM `image` WHERE `cardid` = \'$cardb\'") or die (mysql_error());
$name1 = mysql_query("SELECT * FROM `title` WHERE `cardid` = \'$carda\'") or die (mysql_error());
//$name2 = mysql_query("SELECT * FROM `title` WHERE `cardid` = \'$cardb\'") or die (mysql_error());
$desc1 = mysql_query("SELECT * FROM `desc` WHERE `cardid` = \'$carda\'") or die (mysql_error());
//$desc2 = mysql_query("SELECT * FROM `desc` WHERE `cardid` = \'$cardb\'") or die (mysql_error());
$cardid = $row["cardid"];
echo "<center><table width=\'80%\' border=\'0\' cellpadding=\'5\'>";
echo "<tr>";
echo "<td><img src=\' . $link1 . \' alt=\' . $name1 . \'></td>";
echo "$name1";
echo "<td><center>$card2n</center></td>";
echo "</tr>";
echo "</table>";
echo "<table width=\'60%\' border=\'0\'>";
echo "<tr>";
echo "<td><center><b>Interpretation</b>:";
echo "$desc1 </center></td>";
//echo " $card2d";
echo "</tr>";
echo "</table>";
echo "</center>";
?>[/code]
any/all help is appreciated