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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:29:01+00:00 2026-06-12T23:29:01+00:00

I have a PHP loop that contains a query within the loop I set

  • 0

I have a PHP loop that contains a query within the loop I set two variables to contain certain results, I then want to use the variables outside of the loop. However when I do they just return as undefined. The code is as follows:

<?php 
$standardresult = mssql_query("SELECT Price FROM Extras WHERE ExtraID = 5 ");

while ($standardrow = mssql_fetch_array($standardresult )) { 
    $toughresult = mssql_query("SELECT Price FROM Extras WHERE ExtraID = 6 ");

    while ($toughrow = mssql_fetch_array($toughresult)) {
        $toughprice = $toughrow['Price'];
        $standardprice = $standardrow['Price'];
        echo $standardrow['Price'];
        echo $toughrow['Price'];
        ?>

        <td align="center">
            <input type="radio" name="triple" value="yes" onclick="showPrice('<?php echo $standardrow['Price']; ?>','<?php echo $toughrow['Price']; ?>')" /> yes
        </td>
        <td>&nbsp;</td>
        <td align="center">
            <input type="radio" name="triple" value="no" onclick="showPrice('0','0')" checked="checked" /> no
        </td>

        <?php 
    } 
} 
?>

</tr>
</table>

<input type="hidden" name="ToughPrice" value="<?php echo $toughprice; ?>" />
<input type="hidden" name="StanPrice" value="<?php echo $standardprice; ?>" />

the variables in question are $toughprice and $standardprice. Can anyone tell me where I am going wrong, or if its possible please? Thank you for any help.

  • 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-12T23:29:04+00:00Added an answer on June 12, 2026 at 11:29 pm
    $standardresult = mssql_query("SELECT Price FROM Extras WHERE ExtraID = 5 ");
    while ($standardrow = mssql_fetch_array($result)) { 
    
    $toughresult = mssql_query("SELECT Price FROM Extras WHERE ExtraID = 6 ");
    while ($toughrow = mssql_fetch_array($result)) {
    

    ??? i guess it should be

    $standardresult = mssql_query("SELECT Price FROM Extras WHERE ExtraID = 5 ");
    while ($standardrow = mssql_fetch_array($standardresult)) { 
    
    $toughresult = mssql_query("SELECT Price FROM Extras WHERE ExtraID = 6 ");
    while ($toughrow = mssql_fetch_array($toughresult)) {
    

    maybe it will make a difference …

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

Sidebar

Related Questions

I have the following php loop that takes an array that contains a set
I have a php loop that is echoing out geolocation values. How can I
In PHP I can use a foreach loop such that I have access to
I have nooby PHP question that I can't figure out! I loop through rows
I have a stored proc that does a geospatial query. The proc issues two
I have a php page that takes 2.8 seconds to render. The page contains
I have two PHP arrays. One contains a group name and another contains a
i have a php loop which displays only one record even if there is
So I have a php foreach loop as follows, $i = 1; foreach($rows as
Possible Duplicate: php loop through associative arrays i have a variable which prints an

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.