Jump to content

$_GET array returns empty value


shwetapandit
Go to solution Solved by Psycho,

Recommended Posts

whwn i tried to print $_GET array it does not print anything while i am sending p_id through URL.Why it is so......

 

 

<?php
$conn=mysql_connect("localhost","root","")or die(mysql_error());
mysql_select_db("regis")or die(mysql_error());

$query=mysql_query("SELECT * FROM admin_page")or die(mysql_error());
//$row=mysql_fetch_array($query);

echo "<table width='500' cellspacing='0' cellpadding='0' border='0'>";
echo "<tr align='centre' colspan='1' rowspan='1'><th>p_name</th><th>p_link</th><th>p_content</th></tr>";
while($row=mysql_fetch_array($query)){
$p_id=$row['p_id'];
echo "<tr><td>";
$link=$row['p_name'];

print "<a href=".'show_page.php?p_id=$p_id'.">" .$row['p_name'] . "</a><br>";
          

echo "</td><td>";
echo $row['p_link'];
echo "</td></tr>";

}
echo "<tr><td>";
echo "</table>";
print_r($_GET);
?>

Link to comment
Share on other sites

  • Solution

 

<?php

$conn = mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("regis") or die(mysql_error());

$query = "SELECT * FROM admin_page";
$result = mysql_query($query) or die(mysql_error());

echo "<table width='500' cellspacing='0' cellpadding='0' border='0'>\n";
echo "<tr align='center' colspan='1' rowspan='1'>\n";
echo "<th>p_name</th><th>p_link</th><th>p_content</th>\n"
echo "</tr>";
while($row = mysql_fetch_assoc($result))
{
    echo "<tr>\n";
    echo "<td><a href='show_page.php?p_id={$row['p_id']}'>{$row['p_name']}</a></td>\n";
    echo "<td>{$row['p_link']}</td>\n";
    echo "</tr>\n";
}
echo "</table>\n";

echo "<pre>" . print_r($_GET, 1) . "</pre>";
?>
Link to comment
Share on other sites

<?php

$conn = mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("regis") or die(mysql_error());

$query = "SELECT * FROM admin_page";
$result = mysql_query($query) or die(mysql_error());

echo "<table width='500' cellspacing='0' cellpadding='0' border='0'>\n";
echo "<tr align='center' colspan='1' rowspan='1'>\n";
echo "<th>p_name</th><th>p_link</th><th>p_content</th>\n"
echo "</tr>";
while($row = mysql_fetch_assoc($result))
{
    echo "<tr>\n";
    echo "<td><a href='show_page.php?p_id={$row['p_id']}'>{$row['p_name']}</a></td>\n";
    echo "<td>{$row['p_link']}</td>\n";
    echo "</tr>\n";
}
echo "</table>\n";

echo "<pre>" . print_r($_GET, 1) . "</pre>";
?>

thanks a lot....it works now.

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.