Hello all first time poster, and new to PHP. I'm having some trouble with an array, I'm trying to list several websites (currently all random) that have the same usergroup number as the users from a mysql table but all I'm getting is a blank page. Heres my code:
<?php
$query = mysql_connect("*********", "******", "******") or die(mysql_error());
mysql_select_db('******', $query) or die(mysql_error());
session_start();
if(isset($_SESSION['UserON'])) {
// User is logged in!
$conn ="SELECT url FROM links WHERE usergroup = " . $_SESSION['UserON'] . " LIMIT 0,50";
$result = mysql_query($conn,$query);
while($row=mysql_fetch_row($result))
{
$url[] = $row[1];
}
echo "<p>\n";
foreach( $url as $v )
{
echo $v."<br />\n";
}
echo "</p>\n";
} else {
header('location: login.php');
}
mysql_free_result($result);
?>
but it only outputs the HTML:
<p>
<br />
<br />
</p>
now if I use the following bit I get an output from the database, but since this is not an array i just get a single url.
<?php
$query = mysql_connect("************", "******", "*******") or die(mysql_error());
mysql_select_db('*****', $query) or die(mysql_error());
session_start();
if(isset($_SESSION['UserON'])) {
// User is logged in!
$query = mysql_query("SELECT url FROM links WHERE usergroup = " . $_SESSION['UserON'] . " LIMIT 0,50") or die(mysql_error());
list($url) = mysql_fetch_row($query);
echo $url ;
}
else {
header('location: login2.php');
}
?>
any ideas? thanks