Jump to content


Photo

Help me, I have problem with php and check box form


  • Please log in to reply
11 replies to this topic

#1 thanhnguyen

thanhnguyen
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 05 April 2006 - 08:56 AM

Hi all,
I am new here, I am a newbie to php as well. I am writing a small stuff but got some problems. Can you help me please.

this is the form page [a href=\"http://www.haivenu-vietnam.com/test_script/show_referees.htm\" target=\"_blank\"]http://www.haivenu-vietnam.com/test_script/show_referees.htm[/a] , when visitor choose 3 boxes (I will make visitor only can choose 3 boxes only) it will lead to the [a href=\"http://www.haivenu-vietnam.com/test_script/result.htm\" target=\"_blank\"]result page [/a] (I make it, infact it's not automatically generated from database)

and this is the database:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]CREATE TABLE `referees` (
`id` int(10) unsigned NOT NULL auto_increment,
`number` int(3) NOT NULL default '0',
`name` text NOT NULL,
`telephone` int(11) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

--
-- Dumping data for table `referees`
--

INSERT INTO `referees` VALUES (1, 0, 'Thanh Nguyen', 915678976);
INSERT INTO `referees` VALUES (2, 0, 'Haivenu', 9272917);
INSERT INTO `referees` VALUES (3, 0, 'Nguyen Tat Thanh', 912853450);
INSERT INTO `referees` VALUES (4, 0, 'thanh nguyen', 34683402);
[/quote]

And this is the process file:
<?php
$link = mysql_connect('localhost', 'xxxxx', 'ixxxxx');
 mysql_select_db('haivenu_xxxx')      or die(mysql_error().' : '.mysql_error());
if (!$link) {
   die('Could not connect: ' . mysql_error());
   
}

//query details table begins SELECT * FROM articles $query = "select * from visitors WHERE Name like `%$search%`";
//for($i=0;$i<=20;$i++)if(isset($_POST["number"][$i])) 
$query = mysql_query("select * from referees where number=".$_POST["number"]." ");

//$query = mysql_query("select number from referees order by id DESC LIMIT 10");
while ($row = @mysql_fetch_array($query)) 
{ 
$variable1=$row["number"];
$variable2=$row["name"]; 
$variable3=$row["telephone"]; 
//table layout for results 


print ("$variable1</br>"); 
print ("$variable2</br>"); 
print ("$variable3</br>"); 
}
mysql_close($link);
?>

Can you please check the process file and the form file and if you don't mind please post you solution here.

I highly appreciate your help, indeed.
Thanks in advance.

Thanh Nguyen

#2 thanhnguyen

thanhnguyen
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 06 April 2006 - 01:29 AM

[!--quoteo(post=361887:date=Apr 5 2006, 03:56 PM:name=Thanh Nguyen)--][div class=\'quotetop\']QUOTE(Thanh Nguyen @ Apr 5 2006, 03:56 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Hi all,
I am new here, I am a newbie to php as well. I am writing a small stuff but got some problems. Can you help me please.

this is the form page [a href=\"http://www.haivenu-vietnam.com/test_script/show_referees.htm\" target=\"_blank\"]http://www.haivenu-vietnam.com/test_script/show_referees.htm[/a] , when visitor choose 3 boxes (I will make visitor only can choose 3 boxes only) it will lead to the [a href=\"http://www.haivenu-vietnam.com/test_script/result.htm\" target=\"_blank\"]result page [/a] (I make it, infact it's not automatically generated from database)

and this is the database:
And this is the process file:
<?php
$link = mysql_connect('localhost', 'xxxxx', 'ixxxxx');
 mysql_select_db('haivenu_xxxx')      or die(mysql_error().' : '.mysql_error());
if (!$link) {
   die('Could not connect: ' . mysql_error());
   
}

//query details table begins SELECT * FROM articles $query = "select * from visitors WHERE Name like `%$search%`";
//for($i=0;$i<=20;$i++)if(isset($_POST["number"][$i])) 
$query = mysql_query("select * from referees where number=".$_POST["number"]." ");

//$query = mysql_query("select number from referees order by id DESC LIMIT 10");
while ($row = @mysql_fetch_array($query)) 
{ 
$variable1=$row["number"];
$variable2=$row["name"]; 
$variable3=$row["telephone"]; 
//table layout for results 
print ("$variable1</br>"); 
print ("$variable2</br>"); 
print ("$variable3</br>"); 
}
mysql_close($link);
?>

Can you please check the process file and the form file and if you don't mind please post you solution here.

I highly appreciate your help, indeed.
Thanks in advance.

Thanh Nguyen
[/quote]

Nobody can help??? :(


#3 earl_dc10

earl_dc10
  • Members
  • PipPipPip
  • Advanced Member
  • 71 posts

Posted 06 April 2006 - 01:45 AM

Hi, what specific problems are you having?
got a problem? Google helps many of those in need

#4 thanhnguyen

thanhnguyen
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 06 April 2006 - 01:48 AM

the problem is I am not sure that I have the correct form file and the process php file. If you can check the code for me, I am so grateful.
in brief I don't know how to extract the result from [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]$query = mysql_query("select * from referees where number=".$_POST["number"]." ");
[/quote] and how to print it.

#5 thanhnguyen

thanhnguyen
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 10 April 2006 - 09:19 AM

[!--quoteo(post=362103:date=Apr 6 2006, 08:48 AM:name=Thanh Nguyen)--][div class=\'quotetop\']QUOTE(Thanh Nguyen @ Apr 6 2006, 08:48 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
the problem is I am not sure that I have the correct form file and the process php file. If you can check the code for me, I am so grateful.
in brief I don't know how to extract the result from and how to print it.
[/quote]

hey hey, no one can help me???

#6 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 10 April 2006 - 09:26 AM

To get results from a SELECT query you need to use a function to extract the data, I quite often use mysql_fetch_array()
$query=mysql_query("SELECT * FROM referees WHERE `number`='".$_POST['number']."'");
$fetch=mysql_fetch_array($query);
Then you treat $fetch like an array:
$id=$fetch[id];
$number=$fetch[number];
$name=$fetch[name];
$telephone=$fetch[telephone];

Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#7 thanhnguyen

thanhnguyen
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 10 April 2006 - 09:30 AM

thanks I'll try, please stay for few minutes, I'll inform you the result soon

#8 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 10 April 2006 - 09:31 AM

I'll try but I'm at work and shouldn't really be online - I should be working :-*
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#9 thanhnguyen

thanhnguyen
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 10 April 2006 - 09:41 AM

this is my new process file but it doesn't work :(
<?php
$id=$fetch[id];
$number=$fetch[number];
$name=$fetch[name];
$telephone=$fetch[telephone];
$link = mysql_connect('localhost', 'haivenu_admin', 'iamthanh');
 mysql_select_db('haivenu_test')      or die(mysql_error().' : '.mysql_error());
if (!$link) {
   die('Could not connect: ' . mysql_error());
   
}

//query details table begins SELECT * FROM articles $query = "select * from visitors WHERE Name like `%$search%`";
//for($i=0;$i<=20;$i++)if(isset($_POST["number"][$i])) 
$query=mysql_query("SELECT * FROM referees WHERE `number`='".$_POST['number']."'");
$fetch=mysql_fetch_array($query);
{ 
$variable1=$fetch["number"];
$variable2=$fetch["name"]; 
$variable3=$fetch["telephone"]; 
//table layout for results 


print ("$variable1</br>"); 
print ("$variable2</br>"); 
print ("$variable3</br>"); 
}
mysql_close($link);
?>

any fix ???

#10 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 10 April 2006 - 09:59 AM

Try this, best I can do, got to get back to work now:
<?php
$link = mysql_connect('localhost', 'haivenu_admin', 'iamthanh');
mysql_select_db('haivenu_test')      or die(mysql_error().' : '.mysql_error());
if (!$link) {
   die('Could not connect: ' . mysql_error());
   
}

//query details table begins SELECT * FROM articles $query = "select * from visitors WHERE Name like `%$search%`";
//for($i=0;$i<=20;$i++)if(isset($_POST["number"][$i])) 
$query=mysql_query("SELECT * FROM referees WHERE `number`='".$_POST['number']."'");
$fetch=mysql_fetch_array($query);
$variable1=$fetch["number"];
$variable2=$fetch["name"]; 
$variable3=$fetch["telephone"]; 
//table layout for results 


print ("$variable1</br>"); 
print ("$variable2</br>"); 
print ("$variable3</br>"); 
mysql_close($link);
?>

Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#11 thanhnguyen

thanhnguyen
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 10 April 2006 - 10:03 AM

thanks so much

#12 thanhnguyen

thanhnguyen
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 10 April 2006 - 10:13 AM

it stays the same, I think that maybe the problem is the "check box" form.

When you are free please rewrite all pages for me ...please.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users