mr cracker Posted May 27, 2010 Share Posted May 27, 2010 Hello, i need help with this please. I have this table in my DB I want to store the concepto column´s values in 2 php variables so i'll end up with this: $tax1=IEPS; $tax2=IVA; i'm using this query but its not working: $result = mysql_query("SELECT concepto FROM tbl_nimpuestos WHERE numventa = '$z' "); $row = mysql_fetch_array($result) $tax1 = $row[0]; $tax2 = $row[1]; $z is equal to 28 so i know that's not the problem. THANKS! Quote Link to comment Share on other sites More sharing options...
Alex Posted May 27, 2010 Share Posted May 27, 2010 Try this: $result = mysql_query("SELECT concepto, numventa FROM tbl_nimpuestos WHERE numventa = '$z' "); $row = mysql_fetch_assoc($result) $tax1 = $row['concepto']; $tax2 = $row['numventa']; Quote Link to comment Share on other sites More sharing options...
mr cracker Posted May 27, 2010 Author Share Posted May 27, 2010 Thanks for your reply. Using the above code i get this error: Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\.... on line 370 $tax1 = $row['concepto']; <------ This is Line 370 Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 27, 2010 Share Posted May 27, 2010 You need to loop through the returned set of rows: <?php $tax = array(); $q = "SELECT concepto, numventa FROM tbl_nimpuestos WHERE numventa = '$z' "; $result = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error()); while ($row = mysql_fetch_assoc($result)) { $tax[] = $row['concepto']; } echo '<pre>' . print_r($tax) . '</pre>'; // shows what's in the array ?> Ken Quote Link to comment Share on other sites More sharing options...
mr cracker Posted May 27, 2010 Author Share Posted May 27, 2010 Thankyou both, i had been there stuck for hours now Thank you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.