0

I have a software downloads website thenoblesite.com. Whenever a new version of a software is released(for e.g Google Chrome v17.0.1), I have to change the heading,title to new version name i.e.

<title>Google Chrome v17.0.1</title>
<h3>Google Chrome v17.0.1</h3>

and the download link to:

<a href="thenoblesite.com/downloads/googlechromev17.0.1-thenoblesite.com.exe"> Download Google Chrome v17.0.1</a>

Also I have to change the file name as I have to add "-thenoblesite.com" with every file name.

Doing all these changes is time consuming and some times missing any of these changes or misstyping creates a lot of problem/confusion.

Q1.Is there any way in PHP to do all these changes(heading,title,and download link) by just changing one field?

Q2. Can I use PHP to automatically add "-thenoblesite.com" with the downloaded file name "googlechromev17.0.1.exe" so that the actual filename on server folder remain the same(i.e. googlechromev17.0.1.exe) but whenever someone download it, it automatically become "googlechromev17.0.1-thenoblesite.com.exe"?

(Note: I have used Google chrome just as an example to claify my question. I do agree with people who think that every software should be downloaded from its official page)

Naeem Ul Wahhab
  • 2,465
  • 4
  • 32
  • 59
  • 1
    Use a database.. And for Q2, send the content type header with a custom PHP download page. – jli Nov 27 '11 at 17:12
  • 1
    Why are you providing Chrome downloads in the first place? Do you think Google need help with their bandwidth? :) One should download software only from original, trusted sources because 3rd party downloads could be ridden with viruses or otherwise altered. If you want to help, there are [better ways to do that](http://serverfault.com/questions/185761/productive-uses-for-an-idle-web-server) – Pekka Nov 27 '11 at 17:12
  • 1
    Yeah I just went to the site, and I have to say I agree with the above two comments.. – jli Nov 27 '11 at 17:13
  • 2
    @Pekka friend i have used chrome just as an example. I do agree that one should download softwares from their official site. Chrome is just an example to clarify my question. – Naeem Ul Wahhab Nov 27 '11 at 17:19
  • 1
    WHAT SHOULD EVERY JAVA-SCRIPT PROGRAMMER KNOW? I want to share this most useful post with all my Freinds here. Here is the Link: http://stackoverflow.com/q/2628672/1067051 – Naeem Ul Wahhab Nov 30 '11 at 15:27

1 Answers1

1

For the mySQL query, use something like this:

$result = mysql_query("SELECT id, version, url, etc FROM software ORDER BY id DESC LIMIT 1");
$row = mysql_fetch_assoc($result);

Upon getting the result, echo it to your page like this:

<title><?php echo $row[0]['version'] ?></title>
<h3><?php echo $row[0]['version'] ?></h3>

Of course you will need a different query for each of your software but at least it gives you a general idea of how fetching and output is handled on the beginner level. For more info visit this link:

http://www.php.net/manual/en/function.mysql-query.php

Jhourlad Estrella
  • 3,545
  • 4
  • 37
  • 66
  • 1
    This is nice, but could use a table schema suggestion to go with it to become even better! – Pekka Nov 27 '11 at 17:26
  • 1
    Glad to help. And thanks for appreciating ;) – Jhourlad Estrella Nov 27 '11 at 17:33
  • 1
    @JhourladEstrella You are wellcome friend :-) Can you also kindly help me with the second question Q2. – Naeem Ul Wahhab Nov 27 '11 at 17:37
  • sure. kindly post the link to the question – Jhourlad Estrella Nov 27 '11 at 18:02
  • @JhourladEstrella Actually its a part of the same question above. I will paste the text here: Can I use PHP to automatically add "-thenoblesite.com" with the downloaded file name "googlechromev17.0.1.exe" so that the actual filename on server folder remain the same(i.e. googlechromev17.0.1.exe) but whenever someone download it, it automatically become "googlechromev17.0.1-thenoblesite.com.exe"? – Naeem Ul Wahhab Nov 27 '11 at 18:06
  • It would be better to post a new question so others could also share their grain of salt. Who knows, others may have a better answer than what I have in mind. – Jhourlad Estrella Nov 27 '11 at 18:10