Jump to content

why isn't query working?


ohdang888

Recommended Posts

hey. i'm trying to display "related" games. i have the start of a pretty simple code...

i want to take the name of the game, and put it in a link,

 

for example:

a related game is located at "game.php?title=2deep"

i want the link to just look like "2deep"

 

heres my code. i knwo its wrong though because it not working. its not even coming up with an error, its just blank. (but i have data in my db)


<?php
$type = stripslashes($row['type']);
$related_games = mysql_query("SELECT `title` FROM `game` WHERE `type`= '{$type}' ORDER BY RAND('title') LIMIT 10")
or die(mysql_error());  

while($row = mysql_fetch_array($related_games)){       
        echo '<a href="game.php?title=';
        echo $row[0];
        echo '">';
        echo $row[o];
        echo '</a>';
        echo '<br>';
}
?>

the title put out by those two "$row[0]" needs to be the same title.

 

 

 

 

Link to comment
Share on other sites

try

<?php
$type = stripslashes($row['type']);
$related_games = mysql_query("SELECT `title` FROM `game` WHERE `type`= '{$type}' ORDER BY RAND('title') LIMIT 10")
or die(mysql_error());  

while($row2 = mysql_fetch_array($related_games)){       
        echo '<a href="game.php?title=';
        echo $row2[0];
        echo '">';
        echo $row2[0];//o<>0
        echo '</a>';
        echo '<br>';
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.