473,608 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Fill List/Menu box

Slaxer13
106 New Member
Hi guys,

I want to know how to fill a list/menu box with the column: "id_utiliza dor" from table: "tbl_utilizador es" from database: "db_faq".

And when i select a id on that box i want it to fill the fields, which are ("utilizador ", "email", "password", "administrator" ).

This page is a update page for admin use only (that is taken care of).

This is the update page code (atualizar_regi sto.php):

Expand|Select|Wrap|Line Numbers
  1. <?php require_once('Connections/FAQ.php'); ?>
  2. <?php
  3. if (!isset($_SESSION)) {
  4.   session_start();
  5. }
  6. $MM_authorizedUsers = "1";
  7. $MM_donotCheckaccess = "false";
  8.  
  9. // *** Restrict Access To Page: Grant or deny access to this page
  10. function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  11.   // For security, start by assuming the visitor is NOT authorized. 
  12.   $isValid = False; 
  13.  
  14.   // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  15.   // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  16.   if (!empty($UserName)) { 
  17.     // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
  18.     // Parse the strings into arrays. 
  19.     $arrUsers = Explode(",", $strUsers); 
  20.     $arrGroups = Explode(",", $strGroups); 
  21.     if (in_array($UserName, $arrUsers)) { 
  22.       $isValid = true; 
  23.     } 
  24.     // Or, you may restrict access to only certain users based on their username. 
  25.     if (in_array($UserGroup, $arrGroups)) { 
  26.       $isValid = true; 
  27.     } 
  28.     if (($strUsers == "") && false) { 
  29.       $isValid = true; 
  30.     } 
  31.   } 
  32.   return $isValid; 
  33. }
  34.  
  35. $MM_restrictGoTo = "login_errado.php";
  36. if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  37.   $MM_qsChar = "?";
  38.   $MM_referrer = $_SERVER['PHP_SELF'];
  39.   if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  40.   if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  41.   $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  42.   $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  43.   header("Location: ". $MM_restrictGoTo); 
  44.   exit;
  45. }
  46. ?>
  47. <?php
  48. if (!function_exists("GetSQLValueString")) {
  49. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
  50. {
  51.   if (PHP_VERSION < 6) {
  52.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  53.   }
  54.  
  55.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  56.  
  57.   switch ($theType) {
  58.     case "text":
  59.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  60.       break;    
  61.     case "long":
  62.     case "int":
  63.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  64.       break;
  65.     case "double":
  66.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  67.       break;
  68.     case "date":
  69.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  70.       break;
  71.     case "defined":
  72.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  73.       break;
  74.   }
  75.   return $theValue;
  76. }
  77. }
  78.  
  79. $editFormAction = $_SERVER['PHP_SELF'];
  80. if (isset($_SERVER['QUERY_STRING'])) {
  81.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  82. }
  83.  
  84. if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  85.   $updateSQL = sprintf("UPDATE tbl_utilizadores SET utilizador=%s, password=%s, email=%s WHERE id_utilizador=%s",
  86.                        GetSQLValueString($_POST['utilizador'], "text"),
  87.                        GetSQLValueString($_POST['password'], "text"),
  88.                        GetSQLValueString($_POST['email'], "text"),
  89.                        GetSQLValueString($_POST['id_utilizador'], "int"));
  90.  
  91.   mysql_select_db($database_FAQ, $FAQ);
  92.   $Result1 = mysql_query($updateSQL, $FAQ) or die(mysql_error());
  93.  
  94.   $updateGoTo = "login.php";
  95.   if (isset($_SERVER['QUERY_STRING'])) {
  96.     $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
  97.     $updateGoTo .= $_SERVER['QUERY_STRING'];
  98.   }
  99.   header(sprintf("Location: %s", $updateGoTo));
  100. }
  101.  
  102. $colname_Utilizadores = "-1";
  103. if (isset($_GET['id_utilizador'])) {
  104.   $colname_Utilizadores = $_GET['id_utilizador'];
  105. }
  106. mysql_select_db($database_FAQ, $FAQ);
  107. $query_Utilizadores = sprintf("SELECT * FROM tbl_utilizadores WHERE id_utilizador = %s", GetSQLValueString($colname_Utilizadores, "int"));
  108. $Utilizadores = mysql_query($query_Utilizadores, $FAQ) or die(mysql_error());
  109. $row_Utilizadores = mysql_fetch_assoc($Utilizadores);
  110. $totalRows_Utilizadores = mysql_num_rows($Utilizadores);
  111. ?>
  112. <!doctype html>
  113. <html>
  114. <head>
  115. <meta charset="utf-8">
  116. <title>Atualizar Registo</title>
  117. </head>
  118.  
  119. <body>
  120. <h1>Atualizar Registo</h1>
  121. <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
  122.   <table align="center">
  123.     <tr valign="baseline">
  124.       <td nowrap align="right">ID:</td>
  125.       <td></td>
  126.     </tr>
  127.     <tr valign="baseline">
  128.       <td nowrap align="right">Utilizador:</td>
  129.       <td><input type="text" name="utilizador" value="<?php echo htmlentities($row_Utilizadores['utilizador'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
  130.     </tr>
  131.     <tr valign="baseline">
  132.       <td nowrap align="right">Password:</td>
  133.       <td><input type="text" name="password" value="<?php echo htmlentities($row_Utilizadores['password'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
  134.     </tr>
  135.     <tr valign="baseline">
  136.       <td nowrap align="right">Email:</td>
  137.       <td><input type="text" name="email" value="<?php echo htmlentities($row_Utilizadores['email'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
  138.     </tr>
  139.     <tr valign="baseline">
  140.       <td nowrap align="right">Admin:</td>
  141.       <td><input type="text" name="administrator" value="<?php echo htmlentities($row_Utilizadores['administrator'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
  142.     </tr>
  143.     <tr valign="baseline">
  144.       <td nowrap align="right">&nbsp;</td>
  145.       <td><input type="submit" value="Atualizar Registo"></td>
  146.     </tr>
  147.   </table>
  148.   <input type="hidden" name="MM_update" value="form1">
  149.   <input type="hidden" name="id_utilizador" value="<?php echo $row_Utilizadores['id_utilizador']; ?>">
  150. </form>
  151. <p>&nbsp;</p>
  152. </body>
  153. </html>
  154. <?php
  155. mysql_free_result($Utilizadores);
  156. ?>
  157.  
There is an image attached with the page and where the box should be.

Any additional info needed just ask.

Thanks in advance.
Peace,
Slaxer13

PS: Some things may be in portuguese, if you don't understand just let me know...
Attached Images
File Type: jpg Untitled.jpg (18.3 KB, 63 views)
Jun 1 '15 #1
1 1256
Slaxer13
106 New Member
So i managed to make my listbox show the records...

Expand|Select|Wrap|Line Numbers
  1.         <select name="select" class="textfields" id="ddl_id">
  2.             <option id="0">-- Selecione o ID --</option>
  3.             <?php
  4.                 require("dbconfig.php");
  5.                 $get_ids = mysql_query("SELECT * FROM tbl_utilizadores");
  6.                 while($vertodos = mysql_fetch_array($get_ids)){    
  7.             ?>
  8.             <option id="<?php echo $vertodos['id_utilizador'];?>"><?php echo $vertodos['utilizador'] ?></option>
  9.             <?php } ?>
  10.       </select>
How do i populate the form based on the record i choose in the list box?
Jun 1 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
12042
by: ali poursadri | last post by:
Hi, I want to fill my list box from a dataset in c#. I use adapter and fill command and bind it to a listbox, but it is very slow for large data about 500000 records. How can I view this list rapid? thanks.
4
1611
by: Brian | last post by:
How can I use javascript to select Items in a List/Menu? For example: (value1, value2) will select value1 and value2 in a list menu....
4
13020
by: fizzyfozzy | last post by:
Hi, I am trying to figure out how to show or hide a selection of divs on my page depending on what is selected from a list/menu item, using css & javascript. I have tried to use the script listed here: http://www.thescripts.com/forum/thread88791.html but have been uable to customise it to my needs and could do with some help. My form is asking people how many tickets they would like to an event & depending on their selection I need...
4
6490
by: TechnoAtif | last post by:
Hi ALL I have entered some array values using checkboxes into mysql database through a form. Next iam creating a searchpage where all those cateogories inserted through checkboxes has to be retrieved using list/menu box. When i check only a single checkbox to insert the checked category ,selecting that category through list box gives out the entire data of the user corresponding to that category. However when i check multiple checkboxes and...
4
3390
by: jmartmem | last post by:
Greetings, I have an ASP page containing a Record Insertion Form with a number of fields (mostly text fields and list/menu fields) linked to an Access database. I've created an onsubmit behavior to validate the form but this validates only the text fields. I'm unsure how to similarly validate the list/menu fields; specifically, to create a behavior that acts as a validation alerting the user when no selection is made in the list/menu. I'm...
16
4922
by: stevedude | last post by:
CSS newbie again. I have a problem trying to get coffee mug images within anchor tags to center with my link text for a vertical list menu. If I use the horizontal/vertical properties of "background" or "background-image", the positioning only works with specifying pixels. If I specify the vertical position in pixels, the image gets cut-off at the bottom. I don't know what to do and would appreciate anyone's help. Specifically the code...
5
1874
by: jmartmem | last post by:
Greetings, I am using Dreamweaver CS3 to design an ASP page that contains an Insert Record Form. Within this form are two list/menu form fields that I would like to "synchronize". In other words, let's say one list/menu is where the user selects "Program Name" and a second is for selecting "Project Name". If the user makes a selection from the first list/menu, then the second list/menu is requeried and "refreshed" to show only the project...
1
1598
by: Mala7 | last post by:
Hi I have two list/menu - to be specific they are car Brand menu & car model menu - in my page, what i need to do is to: - make the car model menu dimmed at the start - when a selection made to the car brand menu then the car model menu is enabled and the values in the menu should be related to the car brand choice can i do this with php?? and how?? thanks
0
8087
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8025
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8493
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8179
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6847
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5499
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3993
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4053
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2493
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.