otsem | Code :
- Index.php
- <?php require_once('Connections/cv.php'); ?>
- <?php
- mysql_select_db($database_cv, $cv);
- $query_cv = "SELECT * FROM cv";
- $cv = mysql_query($query_cv, $cv) or die(mysql_error());
- $row_cv = mysql_fetch_assoc($cv);
- $totalRows_cv = mysql_num_rows($cv);
- ?>
- <html>
- <head>
- <title>Document sans titre</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- </head>
- <body>
- <div align="center">
- <table border="1">
- <tr>
- <td>id</td>
- <td>nom</td>
- <td>email</td>
- <td>tel</td>
- <td>fax</td>
- <td>ad1</td>
- <td>ad2</td>
- </tr>
- <?php do { ?>
- <tr>
- <td><?php echo $row_cv['id']; ?></td>
- <td><?php echo $row_cv['nom']; ?></td>
- <td><?php echo $row_cv['email']; ?></td>
- <td><?php echo $row_cv['tel']; ?></td>
- <td><?php echo $row_cv['fax']; ?></td>
- <td><?php echo $row_cv['ad1']; ?><?php echo $row_cv['ad2']; ?></td>
- <td><a href="edit.php?pageNum_cv=<?php echo $row_cv['id']; ?>">wesh</a></td>
- </tr>
- <?php } while ($row_cv = mysql_fetch_assoc($cv)); ?>
- </table>
- </div>
- </body>
- </html>
- <?php
- mysql_free_result($cv);
- ?>
|
Code :
- edit.php
- <?php require_once('Connections/cv.php'); ?>
- <?php
- $currentPage = $HTTP_SERVER_VARS["PHP_SELF"];
- function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "" )
- {
- $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
- }
- $editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
- if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
- $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
- }
- if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form1" )) {
- $updateSQL = sprintf("UPDATE cv SET nom=%s, email=%s, tel=%s, fax=%s, ad1=%s, ad2=%s WHERE id=%s",
- GetSQLValueString($HTTP_POST_VARS['nom'], "text" ),
- GetSQLValueString($HTTP_POST_VARS['email'], "text" ),
- GetSQLValueString($HTTP_POST_VARS['tel'], "text" ),
- GetSQLValueString($HTTP_POST_VARS['fax'], "text" ),
- GetSQLValueString($HTTP_POST_VARS['ad1'], "text" ),
- GetSQLValueString($HTTP_POST_VARS['ad2'], "text" ),
- GetSQLValueString($HTTP_POST_VARS['id'], "int" ));
- mysql_select_db($database_cv, $cv);
- $Result1 = mysql_query($updateSQL, $cv) or die(mysql_error());
- $updateGoTo = "index.php";
- if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
- $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
- $updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
- }
- header(sprintf("Location: %s", $updateGoTo));
- }
- $maxRows_cv = 1;
- $pageNum_cv = 0;
- if (isset($HTTP_GET_VARS['pageNum_cv'])) {
- $pageNum_cv = $HTTP_GET_VARS['pageNum_cv'];
- }
- $startRow_cv = $pageNum_cv * $maxRows_cv;
- mysql_select_db($database_cv, $cv);
- $query_cv = "SELECT * FROM cv";
- $query_limit_cv = sprintf("%s LIMIT %d, %d", $query_cv, $startRow_cv, $maxRows_cv);
- $cv = mysql_query($query_limit_cv, $cv) or die(mysql_error());
- $row_cv = mysql_fetch_assoc($cv);
- if (isset($HTTP_GET_VARS['totalRows_cv'])) {
- $totalRows_cv = $HTTP_GET_VARS['totalRows_cv'];
- } else {
- $all_cv = mysql_query($query_cv);
- $totalRows_cv = mysql_num_rows($all_cv);
- }
- $totalPages_cv = ceil($totalRows_cv/$maxRows_cv)-1;
- $queryString_cv = "";
- if (!empty($HTTP_SERVER_VARS['QUERY_STRING'])) {
- $params = explode("&", $HTTP_SERVER_VARS['QUERY_STRING']);
- $newParams = array();
- foreach ($params as $param) {
- if (stristr($param, "pageNum_cv" ) == false &&
- stristr($param, "totalRows_cv" ) == false) {
- array_push($newParams, $param);
- }
- }
- if (count($newParams) != 0) {
- $queryString_cv = "&" . implode("&", $newParams);
- }
- }
- $queryString_cv = sprintf("&totalRows_cv=%d%s", $totalRows_cv, $queryString_cv);
- ?>
- <html>
- <head>
- <title>Document sans titre</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- </head>
- <body>
- <div align="center">
- <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
- <table align="center">
- <tr valign="baseline">
- <td nowrap align="right">Id:</td>
- <td><?php echo $row_cv['id']; ?></td>
- </tr>
- <tr valign="baseline">
- <td nowrap align="right">Nom:</td>
- <td><input type="text" name="nom" value="<?php echo $row_cv['nom']; ?>" size="32"></td>
- </tr>
- <tr valign="baseline">
- <td nowrap align="right">Email:</td>
- <td><input type="text" name="email" value="<?php echo $row_cv['email']; ?>" size="32"></td>
- </tr>
- <tr valign="baseline">
- <td nowrap align="right">Tel:</td>
- <td><input type="text" name="tel" value="<?php echo $row_cv['tel']; ?>" size="32"></td>
- </tr>
- <tr valign="baseline">
- <td nowrap align="right">Fax:</td>
- <td><input type="text" name="fax" value="<?php echo $row_cv['fax']; ?>" size="32"></td>
- </tr>
- <tr valign="baseline">
- <td nowrap align="right">Ad1:</td>
- <td><input type="text" name="ad1" value="<?php echo $row_cv['ad1']; ?>" size="32"></td>
- </tr>
- <tr valign="baseline">
- <td nowrap align="right">Ad2:</td>
- <td><input type="text" name="ad2" value="<?php echo $row_cv['ad2']; ?>" size="32"></td>
- </tr>
- <tr valign="baseline">
- <td nowrap align="right"> </td>
- <td><input type="submit" value="Mettre à jour l'enregistrement"></td>
- </tr>
- </table>
- <p>
- <input type="hidden" name="MM_update" value="form1">
- <input type="hidden" name="id" value="<?php echo $row_cv['id']; ?>">
- </p>
- </p>
- </form>
- <p>
- <table border="0" width="50%" align="center">
- <tr>
- <td width="23%" align="center"> <?php if ($pageNum_cv > 0) { // Show if not first page ?>
- <a href="<?php printf("%s?pageNum_cv=%d%s", $currentPage, 0, $queryString_cv); ?>"><img src="First.gif" border=0></a>
- <?php } // Show if not first page ?> </td>
- <td width="31%" align="center"> <?php if ($pageNum_cv > 0) { // Show if not first page ?>
- <a href="<?php printf("%s?pageNum_cv=%d%s", $currentPage, max(0, $pageNum_cv - 1), $queryString_cv); ?>"><img src="Previous.gif" border=0></a>
- <?php } // Show if not first page ?> </td>
- <td width="23%" align="center"> <?php if ($pageNum_cv < $totalPages_cv) { // Show if not last page ?>
- <a href="<?php printf("%s?pageNum_cv=%d%s", $currentPage, min($totalPages_cv, $pageNum_cv + 1), $queryString_cv); ?>"><img src="Next.gif" border=0></a>
- <?php } // Show if not last page ?> </td>
- <td width="23%" align="center"> <?php if ($pageNum_cv < $totalPages_cv) { // Show if not last page ?>
- <a href="<?php printf("%s?pageNum_cv=%d%s", $currentPage, $totalPages_cv, $queryString_cv); ?>"><img src="Last.gif" border=0></a>
- <?php } // Show if not last page ?> </td>
- </tr>
- </table></p>
- </div>
- </body>
- </html>
- <?php
- mysql_free_result($cv);
- ?>
|
si quelqu'un a une idée Message édité par otsem le 05-11-2002 à 14:21:46
|