Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

download corresponding file?

Featured Replies

Hey, wondered if someone could help me with how to go about doing the following:

 

I have some code which generates bits of text randomly from a database. But I was wondering if there's a way for a user to download an individual file, which corresponds to the one they're viewing.

 

So say this is my code:

 


<?php

if($_GET['act'] == "generate_quotes") {

$con = mysql_connect("*", "*", "*");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }

mysql_select_db("quote", $con);

$result = mysql_query( " SELECT * FROM `quote`  ORDER BY RAND() LIMIT 0,1 " );



while($row = mysql_fetch_array($result))
 {

 echo '<span class="pink">' . $row['q_quote'] . "</span>";

 }
echo "</table>";

mysql_close($con);

} else { 

echo "<img src=\"vpbgt.png\">";

}
?>

 

And an example of things in the bd are:

 

 


test 1   [id = 1]

test 2   [id = 2]

test 3   [id = 3]

 

If the user clicks the link to generate a piece of text, they can download what's being shown. So if they saw 'test 1' they could click a download link and download 'test1.txt'. But if they were to hit generate again it'd maybe show 'test3' so they'd click the link to download and it'd download 'test3.txt' etc... I'm sure you know the kind of thing I'm after.

 

I've assigned id's to each field in the bd, which I'm sure I'll need, but can someone elaborate on where to go from here? or some examples / tutorials would be great.

 

Thanks for any advice.

 

[PS. The files to download actualy will be PDF's, i can't simply write the text to a document and just include a download link, I just used .txt for an example]

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.