When combining data from two tables using SQL, PHP fails to display the merged values on the table

Apologies for the inconvenience, but I am spending too much time on this: My SQL query is returning the table as expected, but unfortunately I can't seem to display the result on the table.

This is my SQL code:

$ssql = "SELECT * FROM tickets JOIN (SELECT agencias.pais_id, paises.pais_nombre, agencias.EMP_CODE FROM agencias JOIN paises ON paises.pais_id = agencias.pais_id) agpais ON tickets.cod_emp = agpais.EMP_CODE WHERE tipo='NUE' ORDER BY id_ticket DESC" . $criterio; $rs = mysql_query($ssql); $total_registros = mysql_num_rows($rs);

This is my PHP HTML code:

<?php while($resz = mysql_fetch_array($rs)) { ?> <td align="center" valign="middle" bgcolor="#C2DBE7"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"> $resz[pais_nombre]</font></td> <?php } ?>

The var_dump($rs) function returns: resource(18) of type (mysql result)

Answer №1

<?php
foreach($data as $row) {  
?>
<td align="center" valign="middle" bgcolor="#C2DBE7">
    <font face="Verdana, Arial,Helvetica, sans-serif" size="1" color="#000000">
         <?php echo $row['pais_nombre']; ?>
    </font>
</td>

<?php } ?>

Remember to enclose PHP code within PHP tags when including it in HTML.

<?php
//Your PHP code here
?>

Answer №2

$resz[pais_nombre] should be enclosed in single quotes as $resz['pais_nombre']

In addition, it must be surrounded by PHP tags like this

<?php echo $resz['pais_nombre']; ?>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Which is the better option: utilizing the submit event of the form, or incorporating ajax functionality?

Forms are an essential part of my website design, and I often find myself contemplating whether it's better to submit a form using a standard submit button or utilizing Ajax. Typically, I opt for Ajax to prevent the dreaded issue of form re-submission ...

Validate if the JSON data array contains any elements

I'm currently working with an ajax code and I need to determine whether the JSON data contains an array or not. However, despite my attempts, I am still receiving incorrect output. $.ajax({ url: url, type: 'POST', da ...

Troubleshooting problems with routing for an Angular 5 single page application when serving it from a Lumen 5.2 controller

I am facing an issue with serving an Angular SPA from a single routed Lumen endpoint. While the initial boot of the Angular application works fine when navigating directly to the endpoint, loading any child route of the Angular SPA does not work properly. ...

Incorporating SAP Timesheets into a custom web application interface

Looking for a way to streamline the process of entering time sheets into our SAP system, I am exploring integrating them with a user-friendly web interface and an API. Currently, the manual entry through SAPGUI is proving to be a cumbersome task. While res ...

Is there a way to automatically execute all seeders located in the database/seeds folder in Laravel?

Is there a way to automatically run all new seeder files in the seeds directory instead of manually adding them one by one into DatabaseSeeder.php? Note: Automating this process may make seeders independent but could also potentially lead to issues, as me ...

In PHP, validate if an array includes a portion of a specific value

I'm facing a challenge with 2 arrays: $array_x = array( array( "id" => 1, "merchant_reference" => "Ref 12345" ), array( "id" => 2, "merchant_reference" => ...

Where should the Yii transaction be initiated from?

Is the starting point of a transaction important? Example 1: $transaction = Yii::app()->db->beginTransaction(); try { $savedSuccessfully = $object->save(); $transaction->comm ...

adding numerous records simultaneously into a MySQL database

Having trouble with PHP inserting multiple rows simultaneously into a MySQL database. My current code is: $sql = "INSERT INTO database (a,b,c,d,e) VALUES ('$a', '$b' ,'$c', '$d', '$e')"; I am trying to in ...

Dropzone: Sending files after an AJAX request is completed

I'm in the process of developing a CRM php tool, which is functioning well at the moment. However, I need to enhance it with an upload file system feature. After some research, I came across Dropzone.js, which seems to be exactly what I need. The chal ...

Interested in compressing CSS and JavaScript using PHP, but uncertain about the impact on performance and the best methods to implement it?

My current approach involves using PHP to combine multiple css (or js) files into a single file, while also compressing the content using GZIP. For example, the HTML page makes calls to resources like this... <link rel="stylesheet" href="Concat.php?fi ...

Ways to save an array in my database with each value occupying a single row

Is it possible for the form to be submitted with an array of checked values when a user clicks on a checkbox and saves? Each checked value should be saved in the database as a single row. I'm not sure if this is achievable, but I believe you might hav ...

Increase the efficiency of MySQL InnoDB queries in your PHP application

I've encountered some issues with the code in my PHP/MySQL application. While it generally runs smoothly and takes about 3-4 seconds, the first execution (per session) can take up to 2 minutes. I suspect this delay is due to certain automated cache me ...

AJAX is not displaying the expected output

Seeking help on calling a PHP method from JavaScript to query a database and integrate the results into JS functionality. The current 'console.log(output)' in my Ajax returns: "array (size=1) 'action' => string 'getResults&apos ...

Troubleshooting problems with Facebook login authentication

I'm frustrated with the constant changes, instability, and lack of proper documentation on Facebook's platform. Right now, I'm in the process of migrating an app from FBML to an iFrame app due to its deprecation, but I'm facing authenti ...

What is the best way to track the loading progress of an AJAX page in WordPress?

On my WordPress blog, I utilize a plugin known as Advanced Ajax Page Loader. This handy tool loads the next page or post through AJAX and then places it in a specific div on my site. However, I am now interested in incorporating a progress bar to show the ...

Preserving information throughout an online browsing session

Is there a way to save the data about which buttons a user clicked on while visiting our website without using a database? The issue is that any array I use gets reset every time the user is redirected from the page. Note: I'm still learning PHP ...

MySQL automatically inserts a null record if no value is provided

Currently, I am working on a project that involves inserting, viewing, and deleting records. Although everything functions smoothly, an issue persists where a null record is automatically added for some reason. The deletion feature works perfectly for othe ...

Omitting row information from a database using php and jquery

Currently, I am in the process of developing an admin panel and I have encountered a challenge with implementing a confirm dialog before deleting certain data. To achieve this, I am utilizing a plugin known as confirmOn. Below is my current setup: HTML: ...

Issues with sending an AJAX POST request to a PHP script

Hello, I am trying to send a variable from an AJAX JavaScript file to a PHP file. Here is what I have done so far: var request = createRequest(); var deletenode = node.id; window.alert("nodeid=" + deletenode); var vars = "deletenode ...

I want to utilize a select drop-down menu for navigating between pages in my pagination, breaking away from the traditional method of using <a> tags

I have a select dropdown that is dynamically generated for navigation to other pages within the script. It lists the number of pages available for navigation. However, after selecting a page and loading it, the dropdown does not stay selected. I've tr ...