par
Driamar » 02 avr. 2013, 21:43
Bonsoir tout le monde !
Voila j'ai un petit souci.
J'ai créé 2 tables : une table Manga avec id_manga et id_auteur et une autre, Auteur, avec id_auteur et nom.
J'ai créé un tableau dynamique qui reprend la table Manga avec les auteurs ... Le souci que j'ai, est que je récupère dans l'id_auteur l'id et non le nom de l'auteur !
Et je ne vois pas du tout comment faire :/ Il faut que je modifie la requète non ?
Je met le code de ma page si cela peut aider ! Merci par avance
<?php require_once('Connections/MaConnexion.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows_manga = 10;
$pageNum_manga = 0;
if (isset($_GET['pageNum_manga'])) {
$pageNum_manga = $_GET['pageNum_manga'];
}
$startRow_manga = $pageNum_manga * $maxRows_manga;
mysql_select_db($database_MaConnexion, $MaConnexion);
$query_manga = "SELECT manga.titre, auteur.nom FROM manga m INNER JOIN auteur a ON manga.id_auteur=auteur.id_auteur";
$query_limit_manga = sprintf("%s LIMIT %d, %d", $query_manga, $startRow_manga, $maxRows_manga);
$manga = mysql_query($query_limit_manga, $MaConnexion) or die(mysql_error());
$row_manga = mysql_fetch_assoc($manga);
if (isset($_GET['totalRows_manga'])) {
$totalRows_manga = $_GET['totalRows_manga'];
} else {
$all_manga = mysql_query($query_manga);
$totalRows_manga = mysql_num_rows($all_manga);
}
$totalPages_manga = ceil($totalRows_manga/$maxRows_manga)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Document sans titre</title>
</head>
<body>
<table border="1">
<tr>
<td>titre</td>
<td>id_auteur</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_manga['titre']; ?></td>
<td><?php echo $row_manga['id_auteur']; ?></td>
</tr>
<?php } while ($row_manga = mysql_fetch_assoc($manga)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($manga);
?>
Bonsoir tout le monde !
Voila j'ai un petit souci.
J'ai créé 2 tables : une table Manga avec id_manga et id_auteur et une autre, Auteur, avec id_auteur et nom.
J'ai créé un tableau dynamique qui reprend la table Manga avec les auteurs ... Le souci que j'ai, est que je récupère dans l'id_auteur l'id et non le nom de l'auteur !
Et je ne vois pas du tout comment faire :/ Il faut que je modifie la requète non ?
Je met le code de ma page si cela peut aider ! Merci par avance :D
[php]<?php require_once('Connections/MaConnexion.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows_manga = 10;
$pageNum_manga = 0;
if (isset($_GET['pageNum_manga'])) {
$pageNum_manga = $_GET['pageNum_manga'];
}
$startRow_manga = $pageNum_manga * $maxRows_manga;
mysql_select_db($database_MaConnexion, $MaConnexion);
$query_manga = "SELECT manga.titre, auteur.nom FROM manga m INNER JOIN auteur a ON manga.id_auteur=auteur.id_auteur";
$query_limit_manga = sprintf("%s LIMIT %d, %d", $query_manga, $startRow_manga, $maxRows_manga);
$manga = mysql_query($query_limit_manga, $MaConnexion) or die(mysql_error());
$row_manga = mysql_fetch_assoc($manga);
if (isset($_GET['totalRows_manga'])) {
$totalRows_manga = $_GET['totalRows_manga'];
} else {
$all_manga = mysql_query($query_manga);
$totalRows_manga = mysql_num_rows($all_manga);
}
$totalPages_manga = ceil($totalRows_manga/$maxRows_manga)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Document sans titre</title>
</head>
<body>
<table border="1">
<tr>
<td>titre</td>
<td>id_auteur</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_manga['titre']; ?></td>
<td><?php echo $row_manga['id_auteur']; ?></td>
</tr>
<?php } while ($row_manga = mysql_fetch_assoc($manga)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($manga);
?>
[/php]