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
Share on other sites

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']; 

Link to comment
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
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.