Hey there
I am using phpMyAdmin and MySQL to develop a dbase application.
I have a dropdown menu on one of the pages which gets populated automatically with data from a table in the database. The code for this is as follows: - $sql3="SELECT ID, UploadDate FROM Telkom";
-
$result2=mysql_query($sql3);
-
$options="";
-
-
while ($row=mysql_fetch_array($result2)) {
-
-
$id=$row["ID"];
-
$date=$row["UploadDate"];
-
$options.="<OPTION VALUE=\"$id\">".$date;
-
-
The code for the actual dropdown menu is as follows:
-
-
<form name="selectdata" action="select_telkom_data.php" method="post">
-
<SELECT NAME="thedate">
-
<OPTION>Choose
-
<?=$options?>
-
</SELECT>
-
<input type="submit" name="Submit" value="Go">
-
</form>
-
-
As you can see there is an additional php script (select_telkom_data.php). This script is supposed to check the $date variable against the UploadDate table and then return the correct record based on the date the user has selected in the dropdown menu.
-
-
The code for select_telkom_data.php looks like this:
-
-
<?php
-
-
include "admin/dataw.php";
-
include("global.inc.php");
-
$sysadminemail = "webmaster@dtmsi.org";
-
-
process_login();
-
die();
-
-
-
function process_login() {
-
global $dbhost;
-
global $dbuser;
-
global $dbpass;
-
global $db;
-
-
// define homepage and text variables
-
global $homepage;
-
global $homedir;
-
global $sysadminemail;
-
global $userstable;
-
-
-
$date=$_POST['thedate'];
-
$link = mysql_connect("$dbhost", "$dbuser", "$dbpass")
-
or die('Could not connect: ' . mysql_error());
-
echo 'Connected successfully';
-
mysql_select_db("$db") or die('Could not select database');
-
-
$query = "SELECT * FROM Telkom WHERE UploadDate='$date' ";
-
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
-
-
-
$num_rows = mysql_num_rows($result);
-
$row = mysql_fetch_array($result);
-
-
-
// test -- does the date exist
-
if ($num_rows < 1) {
-
print "<HTML>";
-
print "<HEAD>";
-
print "<TITLE>";
-
print "Error";
-
print "</TITLE>";
-
print "<BODY>";
-
print "<CENTER>";
-
print "<B><CENTER>Sorry - no records exist. ";
-
-
-
}
-
else {
-
-
-
include("show_telkom_data.php");
-
-
mysql_close($link);
-
}
-
-
-
}
-
-
?>
[Please use CODE tags when posting source code. Thanks! --pbmods]
The script connects to the database, but it doesn't return any records from the Telkom table. In other words, all I get is the message 'Sorry - no records exist'.
What am I doing wrong?
Thanks guys!
Panna
4 3432 kovik 1,044
Recognized Expert Top Contributor
The value that you are getting from your selection is not the UploadDate, it's the id. The UploadDate is just the label of the option, not the value of it.
if you print_r($_POST) , you'll see the values that are being passed from the form.
The value that you are getting from your selection is not the UploadDate, it's the id. The UploadDate is just the label of the option, not the value of it.
if you print_r($_POST) , you'll see the values that are being passed from the form.
ok, thanks very much! Just one more question though: I'm not entirely sure what to change to make it work. I would REALLY appreciate if you could help me out one more time.
shot!
kovik 1,044
Recognized Expert Top Contributor
Think about it.
What condition are you using to get the data from your database?
What values are you provided to get that data?
Like I said, use print_r($_POST) and figure it out. ^_^
hey, thanks for all your help! I managed to figure it out up to a point where the correct records get selected and displayed.
panna
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Lukelrc |
last post by:
Hi,
I have a dynamically created listbox. I'm trying to get one of the
options selected according to a passed value. This is what i have:
<select name="txtTheme" id="txtTheme">
<option>Select Theme</option>
<%
Dim PassedTheme
|
by: Kris Rockwell |
last post by:
Hello (again),
I have gotten the dropdown list functionality to work through a few tricks
(probably not the most efficient, but it works) but I am not sure how to set
the default selected value. I have tried setting various values to represent
the default value with little success. Essentially I am looking to have the
first item in the list be the default selected item. I noticed in the
properties for a dtat grid you could set a default...
|
by: Merdaad |
last post by:
My drop down list is populated from a static array in my codebehind (c#)
code.
I set the selected index based on some known values(from DB), when the
screen shows up, dropdown list shows that the the first items is selected and
not the one assigned.
Please note that if I hardcode the dropdown items inside the .aspx file,
everything works fine.
Please point me to examples(infopath examples somehow don't show up for me!).
|
by: Mike Wilson |
last post by:
Dear Group,
I have a heirarchical set of database tables, say - "order" and "order_type"
and want to display a series of orders in a grid control, and in place of
the order_type foreign key identifier, I would like a dropdown combo box
(lookup from the "order_type" table) to change the type of the order. I also
need an update command button, a delete row button and also an insert new
row button.
I'm sure this is a very common design...
|
by: koti |
last post by:
hi
i have written some code for selecting an item in combobox dropdown
list which is in datagrid columm. by scrolling the mouse we select any
item from the list.
but by pressing the down key arrow it is not working
can u tell me what are the properties i have to add to slect an item in
processcmdkey method.
| |
by: glenn |
last post by:
Hi folks,
If I want to select the first item in a DropDownList, I need to first select
any item other than the first item and then next I select the first item
which will then fire an event saying that I clicked the first item.
Why can't I just select the first item to get an event to fire without
having to first select any other item.
Thanks for any tips.
|
by: =?Utf-8?B?UmljaA==?= |
last post by:
Greetings,
I have to load 30,000 unique names into a combox. Filling a dataTable takes
only a few milliseconds. But populating the combobox and displaying the list
takes several seconds - way too long. A user selects a name from the
combobox and runs a query.
Originally, this combox was on a form in an MS Access ADP which was linked
directly to our sql server. The combobox populated withins millisecnods.
How can I achieve this...
|
by: Ronny Mandal |
last post by:
Hi!
I have an .aspx with some controls that are created dynamically. The
items are populated into the box by setting the DataSource-property to
a list. In addition I specify the text and value with DataTextField
and DataValueField; this works as expected.
However, my problems arises when I want to read the selected value
(i.e. after a postback caused by a change in the DropDown), the
selected item is always the first item in the...
|
by: SunnySnow29 |
last post by:
Hi,
I have a 2 drop down lists in C# populated with data from a SQL 2005 db.
When a new item of data is inserted the second list must update to reflect the change (the first drop down list will always be unchanged by inserts) and the new value must become the selected value in drop down list 2. I use databind() after the form has autoposted back after the insert but the 1st and 2nd drop down lists default back to the first item in the...
|
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...
|
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,...
| |
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,...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |