Jump to content

alalj23

New Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by alalj23

  1. Trying to pass my results from MYSQL statement as links to card.php. How do I echo out the results as clickable links to card.php passing a get variable so that I can use this variable in card.php. The links should be playerName. <?php include_once 'header.php'; $con = mysql_connect("localhost","*****","******"); mysql_select_db("cards",$con); if (!$con) { die('Could not connect: ' . mysql_error()); } $sql = "SELECT * FROM cards ORDER BY RAND() LIMIT 4"; $results = mysql_query($sql); $array = mysql_fetch_array($results); $num=mysql_num_rows($results); $i=0; while ($i < $num) { $array = mysql_fetch_array($results); echo '<a href="card.php?cardid=' . $array->id . '">' . $array->name . '</a>'; echo "</br>"; $i++; } include_once 'footer.php'; ?>
  2. I'm trying to display 3 results from my table ordered by random. I understand that ORDER BY RAND () is not the most efficient way to do this but I will worry about that later. I get output from the code below but it is the same name three times. Each time I reload it is a different name, but still just the same name three times. Where am I going wrong? <?php include_once 'header.php'; $con = mysql_connect("localhost","*****","******"); mysql_select_db("cards",$con); if (!$con) { die('Could not connect: ' . mysql_error()); } $sql = "SELECT * FROM cards ORDER BY RAND() LIMIT 3"; $results = mysql_query($sql); $array = mysql_fetch_array($results); $num=mysql_num_rows($results); $i=0; while ($i < $num) { echo $array['playerName']; $i++; } include_once 'footer.php'; ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.