01-04-2008, 01:33 PM
(Modification du message : 04-04-2008, 10:43 PM par Mysterarts.)
Tant qu'on ai dans les fonctions en mousse :
Code PHP :
<?php
function doquery($query, $fetch = false)
{
global $link, $root_path;
if(!$link)
{
require($root_path.'includes/config.php');
$link = mysql_connect($dbsettings["server"], $dbsettings["user"], $dbsettings["pass"])
or die ("Erreur de connexion a la bdd: ".mysql_error());
mysql_select_db($dbsettings["name"],$link) or die ("Erreur de selection de bdd: ".mysql_error());
}
$result = mysql_query($query) or die ('Erreur SQL: '.mysql_error().'<br />Requete: '.$query);
if($fetch)
{
$result = mysql_fetch_assoc($result);
}
return $result;
}
function pretty_number($n,$floor=true)
{
if($floor)
{
$n = floor($n);
}
return number_format($n,0,",",".");
}
function array_search_multidim($array, $sub_key, $sub_value) {
$result = "N/D";
foreach($array as $key => $sub_array) {
if($sub_array[$sub_key] == $sub_value) {
$result = $key;
break;
}
}
return $result;
}
[php]