Click here to Skip to main content
15,892,927 members

Pass variable value from one .php to another .php

Steven Borges asked:

Open original thread
I'm very new to PHP and web-design, and I'm having trouble sending the value of a variable to another php.

Here is the current code:
PHP
<?php
$username = "root";
$password = "";
$database = "banners";
						
						mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die ("Não foi possível estabelecer uma ligação a Base de Dados");
$data = mysql_query("SELECT * FROM banner") or die(mysql_error()); 
echo "<table border = 1>"; 
echo "<tr>"; 
echo "<th>Cliente</th>"; 
echo "<th>Status</th>"; 
echo "<th>Visualizar</th>"; 
echo "<th>Excluir</th>"; 
echo "</tr>"; 
 
while($info = mysql_fetch_array( $data )) 
{ 
echo "<tr>"; 
echo "<td value=".$info['cliente'].">".$info['cliente'] . "</td> "; 
if($info['activo']='SIM'){echo "<td>Activo</td>"; }else {echo "<td>Desactivo</td> ";}
echo '<td><a href="visualizar.php" target="_blank"> 
<img src="imagens/search.png" /> 
</a></td>'; 
echo "<td>".$info['ficheiro'] . "</td> "; 
} 
echo "</table>"; 			
?>


The code that is underlined+bolded is supposed to send me to another page, and display the data of the entire information of the table, of the entry the user clicked on.
My problem is letting the other page know that I'm asking it to show "certain" data, or better said, sending the variable form here to another .php file.

I give an image example:
http://i.imgur.com/Og7St.png[^]

I hope I didn't make it sound so complicated.
Thanks in advance !
Tags: SQL, HTML5, PHP

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900