Hello, sorry for my english, i'm french !
I have done a webpage with this to have the theme.
How can i do to connect the database in this page ?
<?php
define('IN_COPPERMINE', true);
require('include/init.inc.php');
pageheader('titre');
?>
<?php
[b]
//HERE IS IT OK OR DOES IT EXIST A BEST CODE ?
$db = mysql_connect('IP', 'Base', 'passe') or die('Erreur de connexion '.mysql_error());
mysql_select_db('base',$db) or die('Erreur de selection '.mysql_error());
[/b]
$sql = 'SELECT .... desc limit 5';
// on envoie la requête
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
// on fait une boucle qui va faire un tour pour chaque enregistrement
echo "<br><br><b>Liste : </b><br><br>";
while($data = mysql_fetch_assoc($req))
{
// on affiche les informations de l'enregistrement en cours
echo '<b>'.$data['nom'].' '.$data['prenom'].'</b> ('.$data['nomconcours'].')';
echo ' <i>date : '.$data['date'].'</i><br>';
}
?>
<?php
pagefooter();
?>
Thank you for all !!
There is no need to connect to the database if the database is same as cpg's database. The connection already stands established since you are including init.inc.php in your script. You can directly use db_query() function to fire the query and fetch the results using mysql_fetch_row or other some other function.
Thank you i will try
Can you post the code i have to put on my first code here ?
thank you a lot !!
The code below is useful only if the table from which u are trying to retrieve the data and the cpg tables are in same database
<?php
define('IN_COPPERMINE', true);
require('include/init.inc.php');
pageheader('titre');
$sql = 'SELECT .... desc limit 5';
// on envoie la requête
$req = db_query($sql);
// on fait une boucle qui va faire un tour pour chaque enregistrement
echo "<br><br><b>Liste : </b><br><br>";
while($data = mysql_fetch_assoc($req))
{
// on affiche les informations de l'enregistrement en cours
echo '<b>'.$data['nom'].' '.$data['prenom'].'</b> ('.$data['nomconcours'].')';
echo ' <i>date : '.$data['date'].'</i><br>';
}
?>
<?php
pagefooter();
?>
Thank you very much, that is exactly that i want !
thanks a lot