Jump to content

Archived

This topic is now archived and is closed to further replies.

thanhnguyen

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

Recommended Posts

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]I make it, infact it's not automatically generated from database[/i])

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:
[code]<?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);
?>
[/code]

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

Share this post


Link to post
Share on other sites
[!--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) [snapback]361887[/snapback][/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]I make it, infact it's not automatically generated from database[/i])

and this is the database:
And this is the process file:
[code]<?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);
?>
[/code]

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??? :(

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[!--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) [snapback]362103[/snapback][/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???

Share this post


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

Share this post


Link to post
Share on other sites
I'll try but I'm at work and shouldn't really be online - I should be working :-*

Share this post


Link to post
Share on other sites
this is my new process file but it doesn't work :(
[code]<?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);
?>[/code]

any fix ???

Share this post


Link to post
Share on other sites
Try this, best I can do, got to get back to work now:
[code]<?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);
?>[/code]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.