Jump to content

Recommended Posts

try something like...

<?php
session_start();
$query = mysql_query("SELECT * FROM `friends` WHERE `friendid`='".$_SESSION['userid']."'") or die(mysql_error());
$row = mysql_fetch_array($query);
echo $row['friendid'][rand(1,count($row))];
?>

...not entirely sure if that would work.

ok i did this

 

      <?php
  require_once '../settings.php';

$q = mysql_query("SELECT friendname FROM friends WHERE username='Admin' ORDER BY friendname");
$count = mysql_num_rows($q);
$results = array();
while ($line = mysql_fetch_array($q)) $results[] = $line;

$split = ceil($count / 2);
// then you can display it in a table
echo "<table>";
for ($i = 1; $i <= $split; $i++) {
    $left = $i; $right = $i + $split;
    echo "<tr>";
    echo "<td>{$results[$left][friendname]}</td>";
    if ($right == $count) { // odd number of results (left column has the extra)
        echo "<td></td>";
    } else {
        echo "<td>{$results[$right][friendname]}</td>";
    }
    echo "</tr>\n";
}
echo "</table>"; 
?> 

 

 

but i only get runnerjp putputted even though my db loos like this

 

id friendname username

Edit Delete 25 runnerjp Admin

Edit Delete 24 Admin runnerjp

Edit Delete 23 Princessemma Admin

Edit Delete 22 Admin Princessemma

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.