Jump to content

Fetch array values.


mr cracker

Recommended Posts

Hello, i need help with this please.

 

I have this table in my DB

Captura-1.jpg

 

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!  :D

Link to comment
https://forums.phpfreaks.com/topic/203138-fetch-array-values/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/203138-fetch-array-values/#findComment-1064366
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.