link problem
Posted: Fri Jul 30, 2010 3:19 am
Hi, I'm newbie here. I would like to ask about link page problem in PHP.
Below is page.php
I want to link to mode 1 in page.php
so i state the link as 'page.php?mode=1', It doesn't work
This method is work in php 5.0.5, but i don't know why newer version of php cannot work.
Can anyone help me, thanks.
Below is page.php
I want to link to mode 1 in page.php
so i state the link as 'page.php?mode=1', It doesn't work
This method is work in php 5.0.5, but i don't know why newer version of php cannot work.
Can anyone help me, thanks.
Code: Select all
<html>
<head><title>page</title></head>
<body>
<?php
$con = mysql_connect("localhost","user","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db", $con);
if($mode=='1')
{
$result = mysql_query( "SELECT field1, field2 FROM table" )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
print "<table width=200 border=1>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td><font face=arial size=1/>$field</font></td>\n";
print "</tr>\n";
}
print "</table>\n";
}
else if($mode=="2")
{
$result = mysql_query( "SELECT name, address FROM table" )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
print "<table width=200 border=1>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td><font face=arial size=1/>$field</font></td>\n";
print "</tr>\n";
}
?>
</body>
</html>