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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:29:11+00:00 2026-05-23T10:29:11+00:00

I am using a loop to go through the result of query and display

  • 0

I am using a loop to go through the result of query and display the data in a grid. I only want to display the delete button in certain rows. I can setup if else statements for that.

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

//HTML code - I am not using echo here just plain html code written below

deleteButton();//I am calling the deleteButton function here.

//HTML code

}

I have a deleteButton function at the top of the page

function deleteButton()
{
echo "<form name='DeleteInfo' method='POST' action='delete.php'>";
echo "<input type='hidden' name='val1' value=$rows[col1]>";
echo "<input type='hidden' name='val2' value=$rows[col2]>";
echo "<input class='center' type='submit' value='Delete'/>";
echo "</form>";
}

I get an error undefined variable rows for col1 and col2. I am assuming it’s a syntax problem.

I have also tried.

echo "<input type='hidden' name='val2' value=$rows['col2']>";
echo "<input type='hidden' name='val2' value='$rows[col2]'>";

This HTML code works

<input type="hidden" name="name1" value="<?php echo $rows['col3']; ?>">

EDIT: Resolved. It was out of scope. I have to use global $rows in the function. Thanks Marc.

  • 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-23T10:29:12+00:00Added an answer on May 23, 2026 at 10:29 am

    Your $rows variable doesn’t exist in the scope of the deleteButton function. You could amend it like this:

    function deleteButton($rows) {
        // etc
    }
    

    and then call it as:

    deleteButton($rows);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using reflection to loop through a Type 's properties and set certain types
Using a for loop, how can I loop through all except the last item
i'm using cursor to loop through a self join table. the query that i
I am using jquery to loop through json object... But some how it doesn't
I'm using tDom to loop through some XML and pull out each element's text().
I'm using the following code to loop through a directory to print out the
I'm using the following syntax to loop through a list collection: For Each PropertyActor
I'm using a foreach to loop through an IList of objects in a Partial
I know how to loop through items of an array using foreach and append
I am using the following function to loop through a couple of open CDB

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.