TheAnt06
Sat 6th Dec '03, 9:36am
<?php
$location = "localhost";
$username = "root";
$password = "";
$database = "dzcom";
$conn = mysql_connect("$location","$username","$password");
if (!$conn) die ("Could not connect MySQL");
mysql_select_db($database,$conn) or die ("Could not open database");
ini_set('display_errors',0);
if ((isset($_SESSION['menu'])) && (!isset($_GET['menu']))) {
$menu = $_SESSION['menu'];
} elseif (isset($_GET['menu'])) {
if ($_SESSION['menu'] == $_GET['menu']) {
if ($_SESSION['expand'] == 0) {
$expand = 1;
} else {
$expand = 0;
}
} else {
$expand = 1;
}
$_SESSION['expand'] = $expand;
$tmenu = $_GET['menu'];
list($menu,$trash) = explode("?",$tmenu,2);
$_SESSION['menu'] = $menu;
}
$expand = $_SESSION['expand'];
list($earl,$trash) = explode("?",$_SERVER['REQUEST_URI'],2);
?>
<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">
<TR><TD><A CLASS="menu" HREF="<?php print($earl); ?>?menu=aaa">xPixel Home</A></TD></TR>
<?php if (($_SESSION['menu'] == "aaa") && ($expand)) { ?>
<TR><TD>
<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">
<TR><TD>
<A HREF="<?
$query = "SELECT pageurl FROM pages";
query($query);
$numrows = mysql_num_rows($result);
while($row = mysql_fetch_array($result)){
echo "$row[pageurl]";
}?>">Page</a>
</TD></TR>
<TR><TD><A HREF="index.php?id=test">Page
</A></TD></TR>
<TR><TD><A HREF="index.php?id=about">About xPixel</A></TD></TR>
<TR><TD><A HREF="a3.php"><IMG SRC="menu2.php?text=A3" ALT="A3"></A></TD></TR>
<TR><TD><A HREF="a4.php"><IMG SRC="menu2.php?text=A4" ALT="A4"></A></TD></TR>
</TABLE></TD></TR><?php } ?>
<TR><TD><A HREF="main.php?menu=home"><IMG SRC="menu.php?text=Home" ALT="Home"></A></TD></TR>
</TABLE>
<?php ini_set('display_errors',1); ?>
That's the full code. The part I am having problems with is:
<TR><TD>
<A HREF="<?
$query = "SELECT pageurl FROM pages";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
while($row = mysql_fetch_array($result)){
echo "$row[pageurl]";
}?>">Page</a>
</TD></TR>
I am trying to get it to display one row result from mySQL as the pageURL. But when I test it out, it shows all the rows .What do I have to do to fix it?
Thanks,
-Ant
$location = "localhost";
$username = "root";
$password = "";
$database = "dzcom";
$conn = mysql_connect("$location","$username","$password");
if (!$conn) die ("Could not connect MySQL");
mysql_select_db($database,$conn) or die ("Could not open database");
ini_set('display_errors',0);
if ((isset($_SESSION['menu'])) && (!isset($_GET['menu']))) {
$menu = $_SESSION['menu'];
} elseif (isset($_GET['menu'])) {
if ($_SESSION['menu'] == $_GET['menu']) {
if ($_SESSION['expand'] == 0) {
$expand = 1;
} else {
$expand = 0;
}
} else {
$expand = 1;
}
$_SESSION['expand'] = $expand;
$tmenu = $_GET['menu'];
list($menu,$trash) = explode("?",$tmenu,2);
$_SESSION['menu'] = $menu;
}
$expand = $_SESSION['expand'];
list($earl,$trash) = explode("?",$_SERVER['REQUEST_URI'],2);
?>
<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">
<TR><TD><A CLASS="menu" HREF="<?php print($earl); ?>?menu=aaa">xPixel Home</A></TD></TR>
<?php if (($_SESSION['menu'] == "aaa") && ($expand)) { ?>
<TR><TD>
<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">
<TR><TD>
<A HREF="<?
$query = "SELECT pageurl FROM pages";
query($query);
$numrows = mysql_num_rows($result);
while($row = mysql_fetch_array($result)){
echo "$row[pageurl]";
}?>">Page</a>
</TD></TR>
<TR><TD><A HREF="index.php?id=test">Page
</A></TD></TR>
<TR><TD><A HREF="index.php?id=about">About xPixel</A></TD></TR>
<TR><TD><A HREF="a3.php"><IMG SRC="menu2.php?text=A3" ALT="A3"></A></TD></TR>
<TR><TD><A HREF="a4.php"><IMG SRC="menu2.php?text=A4" ALT="A4"></A></TD></TR>
</TABLE></TD></TR><?php } ?>
<TR><TD><A HREF="main.php?menu=home"><IMG SRC="menu.php?text=Home" ALT="Home"></A></TD></TR>
</TABLE>
<?php ini_set('display_errors',1); ?>
That's the full code. The part I am having problems with is:
<TR><TD>
<A HREF="<?
$query = "SELECT pageurl FROM pages";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
while($row = mysql_fetch_array($result)){
echo "$row[pageurl]";
}?>">Page</a>
</TD></TR>
I am trying to get it to display one row result from mySQL as the pageURL. But when I test it out, it shows all the rows .What do I have to do to fix it?
Thanks,
-Ant