Multiple Do / While Statements?


Posted on 16th Feb 2014 07:03 pm by admin

I'm still very new to PHP, and running in to a problem when trying to execute a do/while loop inside another one.
What I'm trying to achieve is that I want to display all of the records in one table that match my SQL Query defined as 'Recordset1'.
And, while that is happening, I want to cross-reference my records in a 2nd table, and if the description in Table 2 Matches the Description in Table 1, print a results message right next to the description from 'Recordset1'.

My problem isn't setting up the SQL queries - I'm currently able to get the correct results returned to me, as long as I print the results in a separate table... my problem is getting the results message to print RIGHT NEXT TO the results of 'Recordset1', because the 'Recordset1' results are inside of do/while loop.

There is probably a very simple solution to this, and there's a good possibility that I'm approaching this the wrong way... I just can't wrap my head around it yet...

If anyone has any input, it would be very appreciated!
Thanks!
-d.


Code: [Select]<?php

do {
if(isset($row_Recordset1['description'])) { ?>
<tr>
<td> <?php echo $row_Recordset1['description']?>
<?php

do{
$R1 = $row_Recordset1['description'];
$R2 = $row_Recordset2['description'];

if ($R1== $R2) {
print("It's a Match<br />");
} else
print("No Match<br />")
}while ----????????????? ----
?>

</td>
</tr>
<?php }else break;
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>

No comments posted yet

Your Answer:

Login to answer
180 Like 29 Dislike
Previous forums Next forums
Other forums

Help? Need help on project with templates involving mysql and php.
I'm having a hard time explaining what I want but basically here is what I have in place:

-Da

Problem!
I have another problem, when i run this code i get this error "Parse error: syntax error, unexp

Format timestamp from mysql
When I tried this:
Code: date("m/d/Y H:i A", $row['timestamp'])
I got 12/31/1969 18:

Converting from one format to another
"I have got a date in DD/MM/YYYY but I need it in MM-DD-YYYY. Help!"

Problem with PHP code- simple contact form
Hi Folks,
I'm relativily new to PHP; I know HTML and CSS stuff but I have a problem- I have a co

Regular expression tips or resources
Hello! I'm having some issues implementing the appropriate regex patter to eliminate unwanted charac

Edit MySQL Row Using PHP and HTML Form
Hello,

Here's what I'm trying to do. Build a page where a user enters a MySQL row number in.

Losing 'page' data
I have this code that allows me to update my database. But after updating, I lose the $_GET['page']

PHP error on MySQL insert
I'm sure it's the simplest of issues, but I can't recall why this isn't working.

Code: [Selec

Option box to change variable
Hello, i need help by making a script!

I need to write a file with option box, so a dropdown

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash