Hi,
I've been dabbling with mysql php and xml...
I have managed to learn how to upload xml file into mysql datbase and download the file from mysql database to display the content on the file. However the
What i would like to know is how do i manipulate the php codes to display the content on the file in a proper form?...
So far i have done this: -
<?
-
if(isset($_GET['id']))
-
{
-
include 'config.php';
-
include 'opendb.php';
-
-
$id = $_GET['id'];
-
$query = "SELECT name, type, size, content FROM upload WHERE id = '$id'";
-
$result = mysql_query($query) or die('Error, query failed');
-
//list($name, $type, $size, $content) = mysql_fetch_array($result);
-
$list= mysql_fetch_array($result);
-
while ($list = mysql_fetch_array($result)) {
-
$field1=$content["field1"];
-
$field2=$content["field2"];
-
$field2=$content["field3"];
-
$field2=$content["field4"];
-
$field2=$content["field5"];
-
$field2=$content["field6"];
-
-
// display recordset data
-
echo "<table>";
-
echo "<tr>";
-
echo "<td>Field1 Name =</td>";
-
echo "<td>$field1</td>";
-
echo "</tr><tr>";
-
echo "<td>Field2 Name =</td>";
-
echo "<td>$field2</td>";
-
echo "</tr>";
-
echo "<td>Field3 Name =</td>";
-
echo "<td>$field3</td>";
-
echo "</tr><tr>";
-
echo "<td>Field4Name =</td>";
-
echo "<td>$field4</td>";
-
echo "</tr><tr>";
-
echo "<td>Field5 Name =</td>";
-
echo "<td>$field5</td>";
-
echo "</tr><tr>";
-
echo "<td>Field6 Name =</td>";
-
echo "<td>$field6</td>";
-
echo "</tr><tr>";
-
echo "</table>";
-
}
-
-
-
//header("Content-Disposition: attachment; filename=$name");
-
//header("Content-length: $size");
-
//header("Content-type: $type");
-
// echo $content;
-
-
// include 'closedb.php';
-
exit;
-
}
-
-
?>
-
<html>
-
<head>
-
<title>Download File From MySQL</title>
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-
</head>
-
-
<body>
-
<?
-
include 'config.php';
-
include 'opendb.php';
-
-
$query = "SELECT id, name FROM upload";
-
$result = mysql_query($query) or die('Error, query failed');
-
if(mysql_num_rows($result) == 0)
-
{
-
echo "Database is empty <br>";
-
}
-
else
-
{
-
while(list($id, $name) = mysql_fetch_array($result))
-
{
-
?>
-
<a href="download.php?id=<?=$id;?>"><?=$name;?></a> <br>
-
<?
-
}
-
}
-
//include 'closedb.php';
-
?>
-
</body>
-
</html>
-
but when i execute this ...I neither get an error or a warning.A blank page is displayed.
Please do help.....
Thanks
1 2724 Atli 5,058
Recognized Expert Expert
Hi.
I have a few comments on your code. They may even solve your problem, who knows.
First, PHP code should be encapsulated in <?php .. ?> blocks
<? ..?> may also work on some server, but I would recommend against it. -
<?php
-
echo "This is how it should be";
-
?>
-
-
<?
-
echo "Some servers can be configured to use this, but why take the chance?";
-
?>
-
Second, I do not know if <?= $myVar ?> acctually works, but this is how it should be done:
Third; Use good variable names, like say $NameFiled and $PasswordField and not $Field1, $Field2. Makes debuggin much easier.
You may not have noticed, but you use $Field2 for 4 out of 5 fields your database returns to you.
Lastly, I see you put the $id in your SQL query inside quote marks. If it is, as I hope it is, a numeric value, it should not be encapsulated in quotemarks.
Hope this helps
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: euang |
last post by:
Hi,
I have been using access 2000 for two years on WINDOWS NT to display dynamic
aweb page using ASP
My ISP has now changed to Windows 2003, and I am having major problems
displaying information from MEMO fields within the Access 2000 database. I
have not had any problems before displaying MEMO fields on NT and have tried
various tips to resolve this issue but no luck so far. I was wondering if
anyone had come accross a similar...
|
by: ij |
last post by:
Hi,
I'm trying to submit an image object, along with some other text fields to
another web server from within an ASP page but am stuck on getting the image
to be submitted with the form.
In a bit more detail:
1. When this particular page is executed, I want the server to pull an image
from a db (stored as a BLOB) along with a few other text fields. This part
is easy and I have no problems with it.
|
by: AJ Shankar |
last post by:
Hi,
In the C API, is there any way to execute a query, store all the
results, and somehow find the maximum realized width for each of the
fields before fetching each row?
Otherwise there is no way to efficiently retrieve string data. The
best you can do is either allocate a static buffer of 64K (max size
for a blob) or some smaller buffer that may not actually be able to
contain all the data.
|
by: Dave Crypto |
last post by:
Hi There,
SUMMARY:
I need to know what the actual maximum date limit possible on a row of
a MYSQL database.
MORE DETAILS:
For example, does a MYSQL database only allow 4032 bytes of data to be
|
by: zhaounknown |
last post by:
I have a field set to Image data type, and store a long string(possible other
objects)into it with size 5663, and returned with 5663+28 bytes.
These strings wil be deserialized after retrieving. However failde because
the bytes seems to include some extra bytes with \0 and 0x01 and have 28 more
bytes ahead of the original string.
How could I deal with it? Just remove the first 28 bytes? It this method
formal? I had thought the returned...
| |
by: hamvil79 |
last post by:
I'm implementig a java web application using MySQL as database.
The main function of the application is basically to redistribuite
documents. Those documents (PDF, DOC with an average size around 2Mb)
are stored in BLOB column.
The amount of documents for the first year should not exceed 5/6 Giga,
but I cannot make prevision for the next years.
Those documents are mainly just accessed (update and delete are not so
|
by: Mark |
last post by:
I have a VB 6 program that I have saved an audio file to using DAO and the
appendchunk as is shown at http://support.microsoft.com/kb/103257/EN-US/. ; I
have it working fine in that app (it saves to an access database and I can
save the data back to a file using getchunk and everything works correctly).
The issue is that I am now trying to access the database in VB.NET 2003
through an OleDBDataAdapter (Jet 4.0 connection) and can't get it...
|
by: CD |
last post by:
An application is logging faxes sent in SQL2000 image column type. I have
found code on the net but what it is doing is prompting to save to local
which is fine for single page image. Not good for multiple page faxes. I
have not been able to locate an example to load in the browser or how to
handle multiple image in the one column.
1) Ideally it would be nice to display back in the browser since some may be
multiple images. I am not...
|
by: greywire |
last post by:
So I need to load lots of data into my database.
So I discover LOAD DATA INFILE.
Great! This little gem loads my CSV in blazing times (compared to
parsing the file and doing INSERT for each row). Its still slow on
large files, but just barely acceptable.
Only one problem. It truncates fields to 256 characters, even on a
text field.
|
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: 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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |