I´m new in PHP-MySql world. I come from the Visual Basic MySql Chrystal Report world.
In vb a have a "solution prototype" that I only need to pass a database as parameter and then program the bussiness logic and from there I hava an application in "seconds" . I´m trying to do the same in PHP and MYSQL and everything went fine until I found the following problem.
I crataed a php page called "editrecord.php" that will recibe a query and from it, it will show the fields from the query in edit mode. But I only have learned so for how to show de fields name but no the fields values or content.
if I send the query "select id,name,address from customers WHERE ID = '01' " then the page shows:
ID _______
NAME______
ADDRESS______
And I want to show:
ID 01
NAME : ORANGEL
ADDRESS: FIRST STREET.
Im usign the metada values as show in the PHP MANUAL
This is the code:
Code: Select all
<h1 align="center">EDICION DE REGISTROS
</h1>
<?php
$aCampos = array();
$conn = mysql_connect('localhost', 'root', 'monosofo');
if (!$conn) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('bd001');
$result = mysql_query("select * from presupuestos where codpres = '2008'");
if (!$result) {
die('Query failed: ' . mysql_error());
}
/* get column metadata */
ECHO '<CENTER>';
ECHO '<FORM action="editar.php">';
ECHO '<table width="200" border="1">';
$i = 0;
while ($i < mysql_num_fields($result)) {
// echo "Information for column $i:<br />\n";
$meta = mysql_fetch_field($result, $i);
if (!$meta) {
echo "No information available<br />\n";
}
ECHO "<TR>";
ECHO "<TD>";
ECHO "$meta->name";
ECHO "</TD>";
ECHO "<TD>";
[color=#FF4000]ECHO "$meta->value" ;
[/color]ECHO '<INPUT TYPE="TEXT"> ' ;
ECHO "</TD>";
ECHO "</TR>";
ECHO $b[1] ;
$i++;
}
mysql_free_result($result);
ECHO "</TABLE>";
ECHO '<INPUT TYPE="submit" VALUE="Actualizar"> ' ;
ECHO '<INPUT TYPE="submit" VALUE="Cancelar"> ' ;
ECHO '</FORM>';
ECHO '</CENTER>';
?>
Thnak you all
(Excuse My English)
THIS IS WHAT I GET:

AND I NEED THIS:
