ijamal Posted May 26, 2006 Share Posted May 26, 2006 Dear forum,I am trying to create a GUI using PHP4 that contains the following dropdown multiselect comboboxes,Project Sector (1-Education, 2-Health etc.), Sub Sector(1-Drinking Water, Irrigation Water etc.), Donor(ECHO,USAID,SIDA etc.), Province(1-DRD, 2-Sughd, 3-Khatlon), District( Dist1, Dist2, etc.), Jamoat(Jam1, Jam2 etc.)A user can choose to search the MYSQL database by selecting one or more items in each dropdown list. Once the selection is made. The user can choose what fields are to be viewed, I will create checkboxes with the names of fields that will be visible when the request is submitted.I have already designed and populated the database, including assignment of primary and secondary keys.I just need some pointers about where to start. I have also learnt how to connect to an MYSQL database from PHP and am able to view tables in HTML format.Any help on how to proceed with this project will be most appreciated.Thanks in advance.Irshad Quote Link to comment https://forums.phpfreaks.com/topic/10489-projects-database-in-php-using-mysql/ Share on other sites More sharing options...
Orio Posted May 26, 2006 Share Posted May 26, 2006 [code]$one=$_POST['field1'];$two=$_POST['field2'];$three=$_POST['field3'];//etc'$select="";if(isset($_POST['checkbox1']){$select.="col1";};if(isset($_POST['checkbox2']){$select.=",col2";};if(isset($_POST['checkbox3']){$select.=",col3";};//etc'if(empty($select)){die("Error: Select something!");}$sql="SELECT $select FROM `tablename` WHERE col1='$one' AND col2='$two' AND col3='$three' ....";$result=mysql_query($sql);//Display data[/code]Orio. Quote Link to comment https://forums.phpfreaks.com/topic/10489-projects-database-in-php-using-mysql/#findComment-39150 Share on other sites More sharing options...
ijamal Posted May 27, 2006 Author Share Posted May 27, 2006 Hi Orio,Thanks for your help. I will try this out and see how I progress.Warm regards,Irshad Quote Link to comment https://forums.phpfreaks.com/topic/10489-projects-database-in-php-using-mysql/#findComment-39387 Share on other sites More sharing options...
ijamal Posted May 27, 2006 Author Share Posted May 27, 2006 Dear Orio,I tried to implement the code you kindly gave me however I am not sure how to get it to execute. I am just starting to learn on my own and so please pardon my ignorance. I assume I need to have a checkbox.html doc that contains the checkboxes (Checkbox1, Checkbox2, Checkbox3). I created Checkbox.html with the following code, I am not sure what to assign the value of Checkbox1.<HTML><HEAD></HEAD><BODY><FORM METHOD=POST ACTION=Checkbox.php"><INPUT NAME="Checkbox1" TYPE="Checkbox" VALUE=??In the code you posted previously, I am not sure what these lines mean. Would sincerely appreciate your help.***********************************$one=$_POST['Project.Project_ID'];$two=$_POST['Project.Project_Sector_ID'];$three=$_POST['Project.Sub_Sector_ID'];$select="";if(isset($_POST['checkbox1']){$select.="col1";};if(isset($_POST['checkbox2']){$select.=",col2";};if(isset($_POST['checkbox3']){$select.=",col3";};****************************************This is the code you have given me which I have incorporated into my code...Many thanks for taking your time to help me.Irshad[code]<body bgcolor=#E4E4E4> <FONT COLOR= "blue" face="Verdana"</FONT><center><h1> CP PROJECTS 1996-2006</h1></center><?php$db = mysql_connect("localhost","root");mysql_select_db("CP_PROJECT",$db);$one=$_POST['Project.Project_ID'];$two=$_POST['Project.Project_Sector_ID'];$three=$_POST['Project.Sub_Sector_ID'];$select="";if(isset($_POST['checkbox1']){$select.="col1";};if(isset($_POST['checkbox2']){$select.=",col2";};if(isset($_POST['checkbox3']){$select.=",col3";};if(empty($select)){die("Error: Select something!");}$sql="SELECT $select FROM Project";$result=mysql_query($sql);print "<table border=2 cellspacing=6 cellpadding=6 bordercolor=red>\n";//get field namesprint "<tr BGCOLOR = #FCB103>\n";while ($field = mysql_fetch_field($result)){ print " <th>$field->name</th>\n";} // end whileprint "</tr>\n\n";//get row data as an associative arraywhile ($row = mysql_fetch_assoc($result)){ print "<tr>\n"; //look at each field foreach ($row as $col=>$val){ print " <td BGCOLOR= #B8F475 ALIGN = middle VALIGN = Middle>$val</td> \n"; } // end foreach print "</tr>\n\n";}// end whileprint "</table>\n";?></body></html>[/code][code][quote] Quote Link to comment https://forums.phpfreaks.com/topic/10489-projects-database-in-php-using-mysql/#findComment-39397 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.