2

2 Tables : "Marques" with (id,nom) and "Modeles" with (id,id_parent,nom)

for the moment i can display it without problem as there :

http://www.st-event.be/vehicules/question.php

My problem : I would like to display THE NAME OF THE "MARQUES" with same ID of "ID_PARENT". The Result is always RESOURCE id#

I show my code, so it will be better to understand : `

echo(
       "<table border='1'>
       <tr>
       <td>ID PARENT</td><td>NOM PARENT</td><td>NAME</td>
       </tr>" ) ;
while( $result = mysql_fetch_object( $requete ) )
{
   //tentative d'inscription du parent mais sans succès pour l'instant
   $prt = "SELECT `nom`".
    " FROM `marques`".
    " WHERE `id` = \"". $result->id_parent ."\"" or die(mysql_error());
   $requete2 = mysql_query( $prt, $cnx ) ;
   //---------------------------------------------------------------------

   echo(
       "<tr>

          <td>". $result->id_parent ."</td><td>".$requete2."</td><td>".$result->nom
       ."<td> <a href=\"modification_modeles.php?id=".$result->id."\"><img src=.\img\modifier.png width=15px></a></td><td>") ;
?>`

Would any body can help to find where i did an error ?

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
  • 4
    ***Please [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php).*** [These extensions](http://php.net/manual/en/migration70.removed-exts-sapis.php) have been removed in PHP 7. Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [PDO](http://php.net/manual/en/pdo.prepared-statements.php) and [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) and consider using PDO, [it's really pretty easy](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Jun 16 '17 at 15:44
  • do a join of both tables in your first query! – Jeff Jun 16 '17 at 15:47
  • 1
    `$requete2` now is the resource- you need to fetch array/object first! – Jeff Jun 16 '17 at 15:48
  • Thanks for answer Jay ! I'm Self-made and it's a little complicated for me. Would be possible for you to put me on the path? – Steven D'Heygere Jun 16 '17 at 16:13
  • I feel like you're francophone: I really do not understand what you're trying to do in reality. Cant you tell me more in french? – Envy Hion Jun 16 '17 at 16:16
  • Le même qu'en anglais :) Je souhaite remplacer l'id_parent de la table "MODELES" par le nom de la table "MARQUES" qui à le même ID. ==> SELECT nom FROM marques WHERE id = id_parent – Steven D'Heygere Jun 16 '17 at 19:35
  • No Idee ?:( :( :( – Steven D'Heygere Jun 19 '17 at 13:03

0 Answers0