473,411 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Select

Hi!

Can I use this code to show data of column of a certain database
on the page which I create by writing the following code?
<?php

$open = mysql_connect("localhost", "user", "password");

$data = mysql_db_query("nameofthedatabase", "SELECT * FROM nameofthetable
WHERE nameofthecolumn1 ORDER BY namneofthecolumn2");

while ($rad = mysql_fetch_array ($data)) {

print "<B>";
print $rad["nameofthecolumn1"];
print " ";
print $rad["nameofthecolumn2"];
print "</B><BR>";
print "City:";
print " ";
print $rad["City"];
print "<P>";

}
?>

--
Luigi ( un italiano che vive in Svezia)
https://www.scaiecat-spa-gigi.com/it/svezia.html


Jul 23 '05 #1
3 1361
On 2/7/05 6:24 PM, in article 9N*******************@newsb.telia.net, "Luigi
Donatello Asero" <ja**************@telia.com> wrote:
Hi!

Can I use this code to show data of column of a certain database
on the page which I create by writing the following code?
<?php

$open = mysql_connect("localhost", "user", "password");

$data = mysql_db_query("nameofthedatabase", "SELECT * FROM nameofthetable
WHERE nameofthecolumn1 ORDER BY namneofthecolumn2");

while ($rad = mysql_fetch_array ($data)) {

print "<B>";
print $rad["nameofthecolumn1"];
print " ";
print $rad["nameofthecolumn2"];
print "</B><BR>";
print "City:";
print " ";
print $rad["City"];
print "<P>";

}
?>


The "*" in your SELECT statement will return every column in your database.

$data = mysql_db_query("nameofthedatabase", "SELECT nameofthecolummn1,
nameofthecolumn2 FROM nameofthetable);

You can still use the conditional logic "WHERE nameofthecolumn1 = something"

You can also still sort the recordset "ORDER BY nameofthecolumn2"

-Greg

Jul 23 '05 #2

"Gregory Dean" <gd***@datapex.com> skrev i meddelandet
news:BE2D7FFA.4185%gd***@datapex.com...
On 2/7/05 6:24 PM, in article 9N*******************@newsb.telia.net, "Luigi Donatello Asero" <ja**************@telia.com> wrote:
Hi!

Can I use this code to show data of column of a certain database
on the page which I create by writing the following code?
<?php

$open = mysql_connect("localhost", "user", "password");

$data = mysql_db_query("nameofthedatabase", "SELECT * FROM nameofthetable WHERE nameofthecolumn1 ORDER BY namneofthecolumn2");

while ($rad = mysql_fetch_array ($data)) {

print "<B>";
print $rad["nameofthecolumn1"];
print " ";
print $rad["nameofthecolumn2"];
print "</B><BR>";
print "City:";
print " ";
print $rad["City"];
print "<P>";

}
?>


The "*" in your SELECT statement will return every column in your

database.
Does that mean that if I use "*" in my SELECT statement
I should get all the data which are already in the database?
I tried to send data from a form to the database and to fetch them
afterwards but no data was shown.
I only got the data by e-mail.
The code which I used to send them was:
<?php if (!isset
($_POST['Fornamn']))
{$Fornamn = $_POST ['Fornamn);}
else{$Fornamn = 'not set';}
if (!isset($_POST['Efternamn']))
{$Efternamn = $_POST ['Efternamn'];}
else{$Efternamn = 'not set';}

$connection = mysql_connect("mysql.scaiecat-spa-gigi.com", "scaiecat_?",
"123456")
or die ("Kunde inte skapa koppling!");
mysql_select_db ("scaiecat_?") or die ("Kunde inte välja databas");
$laggTill="INSERT INTO formulär
(Förnamn, Efternamn) Values ('$Fornamn', '$Efternamn');
mysql_query($laggTill) or die ("Det gick inte att lägga till information!");
mysql_close ($connection);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="sv">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta name="keywords" content="Formuläret, förfrågan, semesterbostäder i
Italien, semesterboende, turistlägenheter, boende i Italien för
fritidsändamål ">
<meta name="description" content="Formuläret för förfrågan om
semesterbostäder i Italien">
<LINK rel="alternate"
type="text/html"
href="../it/benvenuti.html" hreflang="it"
lang="it" title="Benvenuti alla Scaiecat Spa Gigi">
<LINK rel="alternate"
type="text/html"
href="../fr/bienvenue.html" hreflang="fr"
lang="fr" title="Bienvenue à la Scaiecat Spa Gigi ">
<LINK rel="alternate"
type="text/html"
href="../sv/valkommen.html" hreflang="fr"
lang="fr" title="Bienvenue à la Scaiecat Spa Gigi ">

<LINK rel="alternate"
type="text/html"
href="../de/willkommen.html" hreflang="de"
lang="en" title="Willkommen bei Scaiecat Spa Gigi">

<link rel=stylesheet href="form2.css" type="text/css">
<title> Scaiecat Spa Gigi-Formulär för förfrågan om semesterbostäder i
Italien</title>


</head>
<body>
<FORM METHOD=POST ACTION="/cgi-bin/formmail.cgi">


<div id="normal">

<INPUT TYPE=HIDDEN NAME=recipient
VALUE="lu*******************@scaiecat-spa-gigi.com">


<DIV CLASS="formular">
<LABEL FOR="Fornamn">Förnamn</LABEL>
<INPUT TYPE="TEXT" NAME="fnamn" id="Fornamn"><br>

<LABEL FOR="Efternamn">Efternamn</LABEL>
<INPUT TYPE="TEXT" NAME="Efternamn" id="Efternamn">

När du klickar på knappen "Skicka" och skickar detta formulär ger du ditt
samtycke till behandling av dina personuppgifter och bekräftar att du tagit
del av och godkänner villkoren för förmedling av hyresrätter till bostäder
för fritidsändamål som anges på denna webbplats.
<INPUT TYPE=SUBMIT VALUE=Skicka>
<INPUT TYPE=RESET VALUE=Radera>
</div>
</div>
</FORM>


</BODY>
</HTML>

--
Luigi ( un italiano che vive in Svezia)
https://www.scaiecat-spa-gigi.com/sv/oversattning.html



Jul 23 '05 #3
On 2/8/05 9:59 AM, in article _s*******************@newsb.telia.net, "Luigi
Donatello Asero" <ja**************@telia.com> wrote:
Does that mean that if I use "*" in my SELECT statement
I should get all the data which are already in the database?
I tried to send data from a form to the database and to fetch them
afterwards but no data was shown.
I only got the data by e-mail.


Ok, a couple of issues here. First, I assumed you were connecting to a MS
SQL server but now I realize you are using mySQL. And, some of these
questions maybe better suited for a PHP forum. But meanwhile, I suggest the
following:

After the INSERT statement, query the mySQL database and verify the record
exists. Your email cgi is using the data from the form fields so there is no
way to tell if the INSERT statement worked.

The "*" means RETURN ALL COLUMNS but the conditional logic determines the
RECORDS that are returned. In the earlier example: " WHERE nameofthecolumn1"
would control which records are retuned in the query. Remove and "WHERE"
statement and get the entire table returned.

You can email me directly concerning PHP issues.

-Greg

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: JT | last post by:
I have an input form for which I've created a "matrix" for user input. Basically, the user chooses a radio button and then through javascript, a select box is displayed to define a value for that...
4
by: Elroyskimms | last post by:
Using SQL 2000... tblCustomer: CustomerID int CompanyName varchar(20) HasRetailStores bit HasWholesaleStores bit HasOtherStores bit tblInvoiceMessages:
4
by: bobsawyer | last post by:
I've been building a series of SELECT lists that are populated dynamically using HTTPRequest. Things are going pretty well, and I've got the whole thing working flawlessly in Mozilla/Firebird....
3
by: dumbledad | last post by:
Hi All, I'm confused by how to replace a SELECT statement in a SQL statement with a specific value. The table I'm working on is a list of words (a column called "word") with an index int...
10
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I...
1
by: serena.delossantos | last post by:
Trying to insert into a history table. Some columns will come from parameters sent to the store procedure. Other columns will be filled with a separate select statement. I've tried storing the...
9
chunk1978
by: chunk1978 | last post by:
hey everyone, i've been trying to solve this problem for 2 days straight, with no end in sight. i would greatly appreciate anyone's help. EXPLANATION: There are 3 Select Menus. The 1st and...
2
by: naima.mans | last post by:
Hello, i want to select 2 following brothers nodes wich are one under another (one closed to another)... i have done one xslt file... but it's not really good.. for example: the xml file:...
4
by: rn5a | last post by:
A Form has 2 select lists. The 1st one whose size is 5 (meaning 5 options are shown at any given time) allows multiple selection whereas the 2nd one allows only 1 option to be selected at a time. ...
6
by: Apaxe | last post by:
In the database i have a table with this information: key_id =1 key_desc =43+34+22+12 I want sum the values in key_desc. Something like: SELECT key_desc FROM table But the result of...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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,...
0
isladogs
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...
0
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...

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.