thanhnguyen Posted April 5, 2006 Share Posted April 5, 2006 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 Quote Link to comment Share on other sites More sharing options...
thanhnguyen Posted April 6, 2006 Author Share Posted April 6, 2006 [!--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??? :( Quote Link to comment Share on other sites More sharing options...
earl_dc10 Posted April 6, 2006 Share Posted April 6, 2006 Hi, what specific problems are you having? Quote Link to comment Share on other sites More sharing options...
thanhnguyen Posted April 6, 2006 Author Share Posted April 6, 2006 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. Quote Link to comment Share on other sites More sharing options...
thanhnguyen Posted April 10, 2006 Author Share Posted April 10, 2006 [!--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??? Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 10, 2006 Share Posted April 10, 2006 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] Quote Link to comment Share on other sites More sharing options...
thanhnguyen Posted April 10, 2006 Author Share Posted April 10, 2006 thanks I'll try, please stay for few minutes, I'll inform you the result soon Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 10, 2006 Share Posted April 10, 2006 I'll try but I'm at work and shouldn't really be online - I should be working :-* Quote Link to comment Share on other sites More sharing options...
thanhnguyen Posted April 10, 2006 Author Share Posted April 10, 2006 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 ??? Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 10, 2006 Share Posted April 10, 2006 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] Quote Link to comment Share on other sites More sharing options...
thanhnguyen Posted April 10, 2006 Author Share Posted April 10, 2006 thanks so much Quote Link to comment Share on other sites More sharing options...
thanhnguyen Posted April 10, 2006 Author Share Posted April 10, 2006 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.