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 8428069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:57:10+00:00 2026-06-10T04:57:10+00:00

This is the first time I’m using this website, I have recently started working

  • 0

This is the first time I’m using this website, I have recently started working on a project where the webpage will display two table, one of the table will gather all the information from a SQL Database and place them in the table along with a button next to each rows allowing you to insert that record to another to the other table, so far, this is the code I have written:

//Include the Following Files
include 'connect.php';

//Select All Price Plans
$query = "SELECT * FROM pricing";
$result = mysql_query($query);

//Print all Plans in Table 
while ($pricing = mysql_fetch_array($result)) 
{
    echo "<table border=1>";
    echo "<tr>";
    echo "<td>" .$pricing['planID'].  "</td>";
    echo "<td>" .$pricing['planTitle']. "</td>";
    echo "<td>" .$pricing['planDescription']. "</td>";
    echo "<td>" .$pricing['planPricing']. "</td>";
    echo "<td>" . **<a href="'. $link .'">BUTTON HERE</a>** . "</td>";
    echo "</tr>";
    echo "<table>";
}  


//Assign $link to Case     
$link = '?run=planA'; 

//Pre-defined Functions
function planA()
{ 
$query = "INSERT into restaurant_plan (`planID`, `planTitle`, `planDescription`, `planPricing`) SELECT * FROM pricing WHERE planID='2' ";
$result = mysql_query($query);
} 

//Setting Case to Run Each Functions
if (isset($_GET['run'])) $linkchoice=$_GET['run']; 
else $linkchoice=''; 

switch($linkchoice)
{       
    case 'planA': 
    planA(); 
    break; 

    case 'planB': 
    planB(); 
    break;              
}     

Could anyone suggest any guide or possibly an example how I could assign a function to each rows? Thanks a lot!

  • 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-06-10T04:57:12+00:00Added an answer on June 10, 2026 at 4:57 am

    your code prints one table for each record in table “pricing”, use this code instead :

    //Select All Price Plans
    $mysqli = new mysqli("hostname", "username", "pass", "dbname");
    
    $query = "SELECT * FROM pricing";
    
    $result = $mysqli->query($query);
    
    //Print all Plans in Table    
    
    echo "Available Price Plans";          
    echo "<table border=1>";
    while ( $pricing = $result->fetch_assoc() ) {
        echo "<tr>";
        echo "<td>" .$pricing['planID'].  "</td>";
        echo "<td>" .$pricing['planTitle']. "</td>";
        echo "<td>" .$pricing['planDescription']. "</td>";
        echo "<td>" .$pricing['planPricing']. "</td>";
        echo "<td>" .'<a href="'. $link .'"><img style="border:none;" src="'. $icon .'" /></a>'. "</td>";
        //print a button as you mentioned
        echo "<td>"."<form action='#' method='get'><input type='hidden' name='id' value='".$pricing['planID']."'/><input type='submit' value='copy'/></form></td>";
        echo "</tr>";
    }
    echo "</table>";
    

    and your function :

    function planA()
    { 
        // get selected plan info
        $query = "SELECT * FROM pricing";
        $result = $mysqli->query($query);
        $row = $res->fetch_assoc();
    
        //copy info to table 'restaurant_plan'
        $query = "INSERT into restaurant_plan (".$_GET["id"].", ".$row["planTitle"].", ".$row["planDescription"].", ".$row["planPricing"].")";
        $result = $mysqli->query($query);
    

    }

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

Sidebar

Related Questions

I am currently working on an ASP.NET MVC2 project. This is the first time
I have two update panels at my ajax page. This is first time I'm
So here I have this first time app I'm working on. When I run
This is my first time working with a WPF datagrid. From what I understand
This is my first time using XML documents. What I'm trying to do is
This is my first time using this site and I am quite new to
when I access any page of my ASP.NET MVC website first time, then this
I'm working on a project and I'm stuck with this problem: I have a
Hi this is first time i am working with my WP7 device and WCF,
I'm using PayPal sandbox for the payment gateway, this is first time I'm trying

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.