Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7412585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:33:50+00:00 2026-05-29T06:33:50+00:00

I have previously asked a question to populate a page depending on which link

  • 0

I have previously asked a question to populate a page depending on which link the user clicked on this post, found here:

How to populate 1 php page differently depending on link clicked?

However I want to try and take it further now as I could make it so that other people are allowed to data therefore I want always be able to create the if statement for them.

So I was thinking something along the lines of populating an array which links to the company name field in the database (which I have already done it to display their name but have coded it manually instead of putting in an array which depends on user input).

Here is my kind of idea or train of thought:

'Declare Array/s

for (user click - use array item relating to the same name as the user clicked link -> [link]==COMPANYNAME-Which is in the database) {

    Display other info relating to that company'

My attempt:

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

    $companyarray[] = $row["company"]; // Declare array to store list of company names inserted to database by each company

    $varcompany[] = $row["company"]; //runs through the company column and populates the array varcompany with those names
    $varwebsite[] = $row["website"]; //runs through the website column and populates the array varwebsite with those names
    $varstory[] = $row["story"]; //runs through the story column and populates the array varstory with the text
}

for ($_GET['link'] == '$companyarray[i]') { // Thanks to Johnny Craig, Crashspeeder and Kolink for the help on this part (I have this working but by manually inserting the company names and creating a seperate if statement for each company) I want to be able to automatically populate this list with each new company added

    echo "<div id='companyname'><a href='http://$varwebsite[0]' />" . $varcompany[0] . "</a></div>";// Displays companies name with link to their website
    echo "<div id='website'><a href='http://$varwebsite[0]' />" . $varwebsite[0] . "</a></div>";// Displays companies website with link
    echo "<img src='images/example.jpg' class='profilePic' />";// At the moment manually entering image link (hopefully will be automatic in future)
    echo "<div id='story'>" . $varstory[0] . "</div>";// Displays a text field from database'

Hope this explains my problem.

********EDITED*********

while($row = mysql_fetch_array($result)) {
    $varcompany[] = $row["company"]; //runs through the company column and populates the array varcompany with those names
    $varwebsite[] = $row["website"]; //runs through the website column and populates the array varwebsite with those names
    $varstory[] = $row["story"]; //runs through the story column and populates the array varstory with the text
}

if($_GET['link']=='miiniim'){
    //print company1 details on single.php page
    echo "<div id='website'><a href='http://$varwebsite[0]' />" . $varwebsite[0] . "</a></div>"; //MIINIIM 1st Company in database
    echo "<div id='companyname'><a href='http://$varwebsite[0]' />" . $varcompany[0] . "</a></div>"; //MIINIIM 1st Company in database
    echo "<img src='images/example.jpg' class='profilePic' />";
    echo "<div id='story'>" . $varstory[0] . "</div>"; //MIINIIM 1st Company in database
}elseif($_GET['link']=='other'){
//print company1 details on single.php page
    echo "<div id='companyname'><a href='http://$varwebsite[1]' />" . $varcompany[1] . "</a></div>"; //MIINIIM 1st Company in database
    echo "<div id='website'><a href='http://$varwebsite[1]' />" . $varwebsite[1] . "</a></div>"; //MIINIIM 1st Company in database
    echo "<img src='images/example.jpg' class='profilePic' />";
    echo "<div id='story'>" . $varstory[1] . "</div>"; //MIINIIM 1st Company in database

********EDITED AGAIN**********

$result = mysql_query("SELECT * FROM ddcompanies WHERE company = {$_GET['link']}");

while($row = mysql_fetch_array($result)) {
    $varcompany = $row["company"];
$varwebsite = $row["website"];
$varstory = $row["story"];
}
print_r($result);
print_r($varcompany);
print_r($varwebsite);
print_r($varstory);

echo "<div id='website'><a href='http://$varwebsite' />" . $varwebsite . "</a></div>";
echo "<div id='companyname'><a href='http://$varwebsite' />" . $varcompany . "</a></div>";
echo "<img src='images/example.jpg' class='profilePic' />";
echo "<div id='story'>" . $varstory . "</div>";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:33:50+00:00Added an answer on May 29, 2026 at 6:33 am
    (QUERY = SELECT * FROM [table] WHERE company = {$_GET['link']};)
    while($row = mysql_fetch_array($result)) {
        $companyarray = $row;
    }
    echo "<div id='companyname'><a href='http://" . $companyarray['website']  . "' />" . $companyarray['company'] . "</a></div>";
    echo "<div id='website'><a href='http://" . $companyarray['website']  . "' />" . $companyarray['website'] . "</a></div>";
    echo "<img src='images/example.jpg' class='profilePic' />";
    echo "<div id='story'>" . $companyarray['story'] . "</div>"
    

    How I understood you correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I previously asked this question here: Stop user from using enter to pass a
This is a related to a previous question I have asked here, see the
This question is related to one I asked previously, see here . As a
I have asked a similar question previously but it was never resolved so here
I found this question asked previously but it contained bad examples and no true
Ok, I have previously asked a similar question to this but it was voted
I have seen this question asked previously but can not find a clear explanation
From this previously asked question , I have noticed that when I move a
this is a follow on question to a previously asked question . I have
I previously asked a question regarding this , got an interesting answer which got

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.