Jump to content

Recommended Posts

I get this error: syntax error, unexpected '{', expecting ';' in C:\wamp\www\warren\billing\editdos.php on line 24

 

<?php	

do {
echo $row['patient'];
}
while ($row = mysql_fetch_assoc ($result)) {	
echo "<tr><td>" . $row['patient'] . "</td><td>" . $row['mrn'] . "</td><td>" .$row['billing_date'] . "</td><td>" .  $row['billing_lvl'] . "</td><td>" . $row['dx1'] . ", " . $row['dx1'] . ", " . $row['dx2'] . ", " . $row['dx3'] . ", " . $row['dx4'] . ", " . $row['dx5'] . ", " . $row['dx6'] . ", " . $row['dx7'] . ", " . $row['dx8'] . ", ";
echo "</tr>";

}


}	
?>

Link to comment
https://forums.phpfreaks.com/topic/136677-solved-unexpected/
Share on other sites

you are using do/while wrong it should probably be:

 

<?php   
while ($row = mysql_fetch_assoc ($result)) {   
   echo "<tr><td>" . $row['patient'] . "</td><td>" . $row['mrn'] . "</td><td>" .$row['billing_date'] . "</td><td>" .  $row['billing_lvl'] . "</td><td>" . $row['dx1'] . ", " . $row['dx1'] . ", " . $row['dx2'] . ", " . $row['dx3'] . ", " . $row['dx4'] . ", " . $row['dx5'] . ", " . $row['dx6'] . ", " . $row['dx7'] . ", " . $row['dx8'] . ", ";
   echo "</tr>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/136677-solved-unexpected/#findComment-713658
Share on other sites

Then how do I echo $row['patient'] BEFORE the while loop (because it is the same in every row)?  If I echo it before then the first record gets skipped when I do the while loop.

 

See this output, patient is same so I want to put patient as a header before the table:

 

Patient	MRN	Billing date	Billing level	Diagnoses
brooks, jeffrey	8001188971	0000-00-00	hpl	khkh, khkh, khkjh, jhkh, , , , , , 
brooks, jeffrey	8001188971	2008-12-09	consm	copd, copd, chf, pneumonia, , , , , , 
brooks, jeffrey	8001188971	2008-12-10	hph	, , , , , , , , , 
brooks, jeffrey	8001188971	2008-12-11	consl	, , , , , , , , , 

Link to comment
https://forums.phpfreaks.com/topic/136677-solved-unexpected/#findComment-713665
Share on other sites

<?php   
while ($row = mysql_fetch_assoc ($result)) {   
   echo "<tr><td>" . $row['patient'] . "</td><td>" . $row['mrn'] . "</td><td>" .$row['billing_date'] . "</td><td>" .  $row['billing_lvl'] . "</td><td>" . $row['dx1'] . ", " . $row['dx1'] . ", " . $row['dx2'] . ", " . $row['dx3'] . ", " . $row['dx4'] . ", " . $row['dx5'] . ", " . $row['dx6'] . ", " . $row['dx7'] . ", " . $row['dx8'] . ", ";
   echo "</tr>";
}
?>

 

You're echoing $row['patient'] within the loop?

 

A

Link to comment
https://forums.phpfreaks.com/topic/136677-solved-unexpected/#findComment-713669
Share on other sites

<?php
for($n=0;$row = mysql_fetch_assoc ($result);$n++) {
   if(!$n){
      echo $row['patient'];
   }
   echo "<tr><td>" . $row['patient'] . "</td><td>" . $row['mrn'] . "</td><td>" .$row['billing_date'] . "</td><td>" .  $row['billing_lvl'] . "</td><td>" . $row['dx1'] . ", " . $row['dx1'] . ", " . $row['dx2'] . ", " . $row['dx3'] . ", " . $row['dx4'] . ", " . $row['dx5'] . ", " . $row['dx6'] . ", " . $row['dx7'] . ", " . $row['dx8'] . ", ";
   echo "</tr>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/136677-solved-unexpected/#findComment-713671
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.