Jump to content

Peuplarchie

Members
  • Posts

    107
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Peuplarchie's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. hahaha... I'm adding my development so if another have the same issue he can see. If.... This way also it gives more info on my issue, i guess. And it shows that I'm working on it...
  2. Getting closer... $sql1= 'SHOW TABLES FROM ' .$db .' LIKE '.$tname; $res1= mysql_query($sql1) OR die('Query 1 error:<br />' .mysql_error()); echo '<table border=1 cellpadding=1 cellspacing=0 width="90%">'; while ( $row= mysql_fetch_row($res1) ) { echo '<tr>'; echo '<td valign="top" align="center">' .$tname. '</td>'; echo '<td>'; $sql2= 'SHOW CREATE TABLE ' .$tname; $res2= mysql_query($sql2) OR die('Query 2 error:<br />' .mysql_error()); while ( $table_def= mysql_fetch_row($res2) ) { for ($i=1; $i<count($table_def); $i++) { echo '<pre>' .$table_def[$i]. '</pre>'; } } echo '</tr>'; } echo '</table>';
  3. Good day all, I'm working on a thing which lets the member create, edit, delet it's own table and data. I have a form in a table which list the table data, this form should add a row. Here is it's code : $tid = $_GET['id']; $tname = $_GET['tname']; $con = mysql_connect($server, $login, $password); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($db, $con); $query = "SELECT * FROM $tname"; $resultv = mysql_query($query); if (($resultv)||(mysql_errno == 0)) { echo "<table width='100%' border=\"1\">\n"; echo "<tr>"; echo "<td align='center'><b>Options</b></td>"; if (mysql_num_rows($resultv)>0) { //loop thru the field names to print the correct headers $i = 0; while ($i < mysql_num_fields($resultv)) { echo "<th>". mysql_field_name($resultv, $i) . " <a href=\"tableau.php?act=delcol&opt=tableau&tname=".$tname."&cname=".mysql_field_name($resultv, $i)."\" title=\"DELETE COLUMN : ". mysql_field_name($resultv, $i) . "\"><img src=\"Images/stock_delete-column.png\" align=\"bottom\"></a></th>\n"; $i++; } echo "</tr>"; echo "<tr><form name=\"formadd\" method=\"post\" action=\"tableau.php?add=row\">\n"; //loop thru the field names to print the correct headers $i = 0; echo "<td align='center'><input type=\"submit\" value=\"Ajouter\"></td>"; while ($i < mysql_num_fields($resultv)) { echo "<td align='center'><input type=\"text\" name=\"". mysql_field_name($resultv, $i) . "\"</td>\n"; $i++; } echo "</form></tr>\n"; //display the data while ($rowv = mysql_fetch_array($resultv,MYSQL_ASSOC)) { echo "<tr><td><br></td>\n"; foreach ($rowv as $data) { if ($data == "") { echo "<td align='center'><br></td>\n"; }else{ echo "<td align='center'>". $data . "</td>\n"; } } } }else{ echo "<tr><td colspan='" . ($i+1) . "'>No Results found!</td></tr>\n"; } echo "</table>"; }else{ echo "Error in running query :". mysql_error(); } My issue is to receive the data and insert it in the database. I have know clue how to put the POSTs into variable so I can Insert it in the query.. Can somebody help me ? Take care !
  4. Impressive, here is what I come back with from before your post. how to implement it with a foreach loop. Let says instead I use index 0 to give me the whole piece and I replace the whole string with anther with the "number" index 1 with the formated html. See code preg_match_all('/\*&([a-z0-9]+)&\*/i',$tache,$out, PREG_SET_ORDER); echo $out[0][0] . ", " . $out[1][0] . ", " . $out[2][0] . ", " . $out[3][0] . ", " . $out[4][0] . "\n"; $i = 0; foreach ($out[$i][0] as &$value) { $value = str_replace("*&","<div class=\"progress-containers\"><div style=\"width:",$value); $value = str_replace("&*","%\">$value[$i][1]</div></div>",$value); $i++; }
  5. Good day to you all, I'm looking for a way to retrieve the text in between *& &* and put it's content into a $var. for each occurrence with in a string. $occu[0] = "dsfsdf"; $occu[1] = "10"; $occu[2] = "10sct"; Is there a way to do this ? I know how to do it but not recusively. function get_string_between($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } $parsed = get_string_between($tache, "*&", "&*"); $tache = str_replace("*&","<div class=\"progress-containers\"><div style=\"width:",$tache); $tache = str_replace("&*","%\">$parsed</div></div>",$tache); Can somebody can give me a tips ?
  6. Good day to everybody ! I'm working on a small to-do list. I have created a text editor to add no todo to it. Here is the code : <script> //modified version of http://www.webmasterworld.com/forum91/4686.htm //myField accepts an object reference, myValue accepts the text string to add function insertAtCursor(myField, myValue) { //fixed scroll position textAreaScrollPosition = myField.scrollTop; //IE support if (document.selection) { myField.focus(); //in effect we are creating a text range with zero //length at the cursor location and replacing it //with myValue sel = document.selection.createRange(); sel.text = myValue; //Mozilla/Firefox/Netscape 7+ support } else if (myField.selectionStart || myField.selectionStart == '0') { myField.focus(); //Here we get the start and end points of the //selection. Then we create substrings up to the //start of the selection and from the end point //of the selection to the end of the field value. //Then we concatenate the first substring, myValue, //and the second substring to get the new value. var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); myField.setSelectionRange(endPos+myValue.length, endPos+myValue.length); } else { myField.value += myValue; } //fixed scroll position myField.scrollTop = textAreaScrollPosition; } </script> <form action="ajoutage.php" method="post" name="ajout" id="ajout"> <table cellpadding="0" cellspacing"0" border="0"> <input type="hidden" name="sujet" value="<?PHP echo $_GET['sujet']; ?>"/> <input type="hidden" name="categorie" value="<?PHP echo $_GET['categorie']; ?>"/> <tr><td width="85px">Titre : </td><td><input type="text" name="titre"/></td> <td></td> <td>Ajouteur : </td><td align="right"><input type="text" name="ajouteur" value="<?PHP echo $qui; ?>"/></td> </tr> <tr><td width="85px">Sujet : </td><td><input type="text" name="sujet"/></td> <td></td> <td>Status : </td><td align="right"><input type="text" name="status"/></td> </tr> <tr><td width="85px">Catégorie : </td><td><input type="text" name="categorie"/></td> <td></td> <td>Niveau : </td><td align="right"><input type="text" name="niveau"/></td> </tr> <tr><td colspan="5">Tâche : <a href="#" onClick="insertAtCursor(document.ajout.tache, '<tr><td></td>\n<td>*&0&*</td>\n</tr>\n')">Progress</a> | <a href="#" onClick="insertAtCursor(document.ajout.tache, '<tr colspan=3>\n<td></td>\n</tr>\n')">Pleinne</a> | <br><textarea name="tache" id="tache" cols="70" rows="20" wrap="off" spellcheck="false"></textarea></td> </tr> <tr><td colspan="5"><input type="submit" value="Ajouter"/></td></tr> </table> </form> It works very fine, as you can see there is to links that is use to add some text in the textarea, where ever the cursor is. Where it starts : I have also created another form to modify the todo's once they are created. The only problem here is that my 2 links for adding text to the textarea don't work at all, they do nothng, no error shown, no text added. Here is the code use to modify the todos once created: <script type="text/javascript"> //modified version of http://www.webmasterworld.com/forum91/4686.htm //myField accepts an object reference, myValue accepts the text string to add function insertAtCursor(myField, myValue) { //fixed scroll position textAreaScrollPosition = myField.scrollTop; //IE support if (document.selection) { myField.focus(); //in effect we are creating a text range with zero //length at the cursor location and replacing it //with myValue sel = document.selection.createRange(); sel.text = myValue; //Mozilla/Firefox/Netscape 7+ support } else if (myField.selectionStart || myField.selectionStart == '0') { myField.focus(); //Here we get the start and end points of the //selection. Then we create substrings up to the //start of the selection and from the end point //of the selection to the end of the field value. //Then we concatenate the first substring, myValue, //and the second substring to get the new value. var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); myField.setSelectionRange(endPos+myValue.length, endPos+myValue.length); } else { myField.value += myValue; } //fixed scroll position myField.scrollTop = textAreaScrollPosition; } </script> <?php $con = mysql_connect("localhost","XXXXXX","XXXXXX"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("XXXXXX", $con); $id = $_GET['id']; $qui = $_GET['qui']; $sujet = $_GET['sujet']; $categorie = $_GET['categorie']; $result = mysql_query("SELECT * FROM todo where id='$id'"); while($row = mysql_fetch_array($result)) { echo " <form action=\"modifiage.php\" name=\"ajout\" id=\"ajout\" method=\"post\"> <table cellpadding=\"0\" cellspacing\"0\" border=\"0\"> <input type=\"hidden\" name=\"id\" value=\"" . $row['id'] . "\"/> <input type=\"hidden\" name=\"qui\" value=\"" . $row['ajouteur'] . "\"/> <input type=\"hidden\" name=\"sujet\" value=\"" . $row['sujet'] . "\"/> <input type=\"hidden\" name=\"categorie\" value=\"" . $row['categorie'] . "\"/> <tr><td width=\"85px\">Titre : </td><td><input type=\"text\" name=\"titre\" value=\"" . $row['titre'] . "\"/></td> <td></td> <td>Ajouteur : </td><td align=\"right\"><input type=\"text\" name=\"ajouteur\" value=\"" . $row['ajouteur'] . "\"/></td> </tr> <tr><td width=\"85px\">Sujet : </td><td><input type=\"text\" name=\"sujet\" value=\"" . $row['sujet'] . "\"/></td> <td></td> <td>Status : </td><td align=\"right\"><input type=\"text\" name=\"status\" value=\"" . $row['status'] . "\"/></td> </tr> <tr><td width=\"85px\">Catégorie : </td><td><input type=\"text\" name=\"categorie\" value=\"" . $row['categorie'] . "\"/></td> <td></td> <td>Niveau : </td><td align=\"right\"><input type=\"text\" name=\"niveau\" value=\"" . $row['niveau'] . "\"/></td> </tr> <tr> "; $tache = $row['tache']; $tache = str_replace("<div class=\"progress-containers\"><div style=\"width:","*&",$tache); $tache = str_replace("%\"><br></div></div>","&*",$tache); $onmouse = '<tr onMouseOver="this.className=**highlight**" onMouseOut="this.className=**normal**"><td>'; $tache = str_replace($onmouse,"<tr><td>",$tache); echo " <td colspan=\"5\">Tâche : <a href=\"#\" onClick=\"insertAtCursor(document.ajout.tache, '<tr><td></td>\n<td>*&0&*</td>\n</tr>\n')\">Progress</a> | <a href=\"#\" onClick=\"insertAtCursor(document.ajout.tache, '<tr colspan=3>\n<td></td>\n</tr>\n')\">Pleinne</a> | <br><textarea name=\"tache\" id=\"tache\" cols=\"70\" rows=\"20\" wrap=\"off\" spellcheck=\"false\">" . $tache . "</textarea></td> </tr> <tr><td colspan=\"5\"><input type=\"submit\" value=\"Modifier\"/></td> </tr> </table> </form> "; } mysql_close($con); ?>
  7. Good day to you all, I new in php MySQL classes and I have found a nice model. (See code 1 later) I would like to add to it but I'm not sure how, can somebody help me, any help is good to learn ! Code 1 (Model Class) <?php # Name: Database.class.php # File Description: MySQL Class to allow easy and clean access to common mysql commands # Author: ricocheting # Web: http://www.ricocheting.com/ # Update: 2010-05-08 # Version: 3.1.3 # Copyright 2003 ricocheting.com /* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ //require("config.inc.php"); //$db = Database::obtain(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); //$db = Database::obtain(); ################################################################################################### ################################################################################################### ################################################################################################### class Database{ // debug flag for showing error messages public $debug = true; // Store the single instance of Database private static $instance; private $server = ""; //database server private $user = ""; //database login name private $pass = ""; //database login password private $database = ""; //database name private $error = ""; ####################### //number of rows affected by SQL query public $affected_rows = 0; private $link_id = 0; private $query_id = 0; #-############################################# # desc: constructor private function __construct($server=null, $user=null, $pass=null, $database=null){ // error catching if not passed in if($server==null || $user==null || $pass==null || $database==null){ $this->oops("Database information must be passed in when the object is first created."); } $this->server=$server; $this->user=$user; $this->pass=$pass; $this->database=$database; }#-#constructor() #-############################################# # desc: singleton declaration public static function obtain($server=null, $user=null, $pass=null, $database=null){ if (!self::$instance){ self::$instance = new Database($server, $user, $pass, $database); } return self::$instance; }#-#obtain() #-############################################# # desc: connect and select database using vars above # Param: $new_link can force connect() to open a new link, even if mysql_connect() was called before with the same parameters public function connect($new_link=false){ $this->link_id=@mysql_connect($this->server,$this->user,$this->pass,$new_link); if (!$this->link_id){//open failed $this->oops("Could not connect to server: <b>$this->server</b>."); } if(!@mysql_select_db($this->database, $this->link_id)){//no database $this->oops("Could not open database: <b>$this->database</b>."); } // unset the data so it can't be dumped $this->server=''; $this->user=''; $this->pass=''; $this->database=''; }#-#connect() #-############################################# # desc: close the connection public function close(){ if(!@mysql_close($this->link_id)){ $this->oops("Connection close failed."); } }#-#close() #-############################################# # Desc: escapes characters to be mysql ready # Param: string # returns: string public function escape($string){ if(get_magic_quotes_runtime()) $string = stripslashes($string); return @mysql_real_escape_string($string,$this->link_id); }#-#escape() #-############################################# # Desc: executes SQL query to an open connection # Param: (MySQL query) to execute # returns: (query_id) for fetching results etc public function query($sql){ // do query $this->query_id = @mysql_query($sql, $this->link_id); if (!$this->query_id){ $this->oops("<b>MySQL Query fail:</b> $sql"); return 0; } $this->affected_rows = @mysql_affected_rows($this->link_id); return $this->query_id; }#-#query() #-############################################# # desc: does a query, fetches the first row only, frees resultset # param: (MySQL query) the query to run on server # returns: array of fetched results public function query_first($query_string){ $query_id = $this->query($query_string); $out = $this->fetch($query_id); $this->free_result($query_id); return $out; }#-#query_first() #-############################################# # desc: fetches and returns results one line at a time # param: query_id for mysql run. if none specified, last used # return: (array) fetched record(s) public function fetch($query_id=-1){ // retrieve row if ($query_id!=-1){ $this->query_id=$query_id; } if (isset($this->query_id)){ $record = @mysql_fetch_assoc($this->query_id); }else{ $this->oops("Invalid query_id: <b>$this->query_id</b>. Records could not be fetched."); } return $record; }#-#fetch() #-############################################# # desc: returns all the results (not one row) # param: (MySQL query) the query to run on server # returns: assoc array of ALL fetched results public function fetch_array($sql){ $query_id = $this->query($sql); $out = array(); while ($row = $this->fetch($query_id)){ $out[] = $row; } $this->free_result($query_id); return $out; }#-#fetch_array() #-############################################# # desc: does an update query with an array # param: table, assoc array with data (not escaped), where condition (optional. if none given, all records updated) # returns: (query_id) for fetching results etc public function update($table, $data, $where='1'){ $q="UPDATE `$table` SET "; foreach($data as $key=>$val){ if(strtolower($val)=='null') $q.= "`$key` = NULL, "; elseif(strtolower($val)=='now()') $q.= "`$key` = NOW(), "; elseif(preg_match("/^increment\((\-?\d+)\)$/i",$val,$m)) $q.= "`$key` = `$key` + $m[1], "; else $q.= "`$key`='".$this->escape($val)."', "; } $q = rtrim($q, ', ') . ' WHERE '.$where.';'; return $this->query($q); }#-#update() #-############################################# # desc: Add column # param: # returns: public function alter($table, $data){ $q="ALTER `$table` ADD COLUMN "; foreach($data as $key=>$val){ if(strtolower($val)=='null') $q.= "`$key` = NULL, "; elseif(strtolower($val)=='now()') $q.= "`$key` = NOW(), "; elseif(preg_match("/^increment\((\-?\d+)\)$/i",$val,$m)) $q.= "`$key` = `$key` + $m[1], "; else $q.= "`$key`='".$this->escape($val)."', "; } $q = rtrim($q, ', ') . ' WHERE '.$where.';'; return $this->query($q); }#-#alter() #-############################################# # desc: Duplicate row # param: # returns: #-#duplicate() #-############################################# # desc: does an insert query with an array # param: table, assoc array with data (not escaped) # returns: id of inserted record, false if error public function insert($table, $data){ $q="INSERT INTO `$table` "; $v=''; $n=''; foreach($data as $key=>$val){ $n.="`$key`, "; if(strtolower($val)=='null') $v.="NULL, "; elseif(strtolower($val)=='now()') $v.="NOW(), "; else $v.= "'".$this->escape($val)."', "; } $q .= "(". rtrim($n, ', ') .") VALUES (". rtrim($v, ', ') .");"; if($this->query($q)){ return mysql_insert_id($this->link_id); } else return false; }#-#insert() #-############################################# # desc: frees the resultset # param: query_id for mysql run. if none specified, last used private function free_result($query_id=-1){ if ($query_id!=-1){ $this->query_id=$query_id; } if($this->query_id!=0 && !@mysql_free_result($this->query_id)){ $this->oops("Result ID: <b>$this->query_id</b> could not be freed."); } }#-#free_result() #-############################################# # desc: throw an error message # param: [optional] any custom error to display private function oops($msg=''){ if(!empty($this->link_id)){ $this->error = mysql_error($this->link_id); } else{ $this->error = mysql_error(); $msg="<b>WARNING:</b> No link_id found. Likely not be connected to database.<br />$msg"; } // if no debug, done here if(!$this->debug) return; ?> <table align="center" border="1" cellspacing="0" style="background:white;color:black;width:80%;"> <tr><th colspan=2>Database Error</th></tr> <tr><td align="right" valign="top">Message:</td><td><?php echo $msg; ?></td></tr> <?php if(!empty($this->error)) echo '<tr><td align="right" valign="top" nowrap>MySQL Error:</td><td>'.$this->error.'</td></tr>'; ?> <tr><td align="right">Date:</td><td><?php echo date("l, F j, Y \a\\t g:i:s A"); ?></td></tr> <?php if(!empty($_SERVER['REQUEST_URI'])) echo '<tr><td align="right">Script:</td><td><a href="'.$_SERVER['REQUEST_URI'].'">'.$_SERVER['REQUEST_URI'].'</a></td></tr>'; ?> <?php if(!empty($_SERVER['HTTP_REFERER'])) echo '<tr><td align="right">Referer:</td><td><a href="'.$_SERVER['HTTP_REFERER'].'">'.$_SERVER['HTTP_REFERER'].'</a></td></tr>'; ?> </table> <?php }#-#oops() }//CLASS Database ################################################################################################### ?> Now I'm trying to add a function that would let me add column. Please look at function alter in the code1 and if you can lead me tomy understanding. Thanks!
  8. Good day to you all, I'm trying to read a directory and for each file add : path, name, ext, width and height to my database. Right now the only thing I had succeed in to list the image directory. I have tried out to add it to the database but no reaction, nothing is added to the db, no error ? Here is my code: <?php // Connect to database $con = mysql_connect("localhost","111",111"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("images", $con); $imgdir = 'Images/'; // the directory, where your images are stored $realimgdir = "Images/"; $allowed_types = array('png','jpg','jpeg','gif','bmp'); // list of filetypes you want to show $dimg = opendir($imgdir); while($imgfile = readdir($dimg)) { if(in_array(strtolower(substr($imgfile,-3)),$allowed_types)) { $a_img[] = $imgfile; sort($a_img); reset ($a_img); } } $totimg = count($a_img); // total image number for($x=0; $x < $totimg; $x++) { $size = getimagesize($imgdir.'/'.$a_img[$x]); // do whatever $halfwidth = ceil($size[0]/2); $halfheight = ceil($size[1]/2); $rid = $realimgdir; $fname = substr($a_img[$x],0, -4); $extens = substr($a_img[$x], -3); $iwidth = $size[0]; $iheight = $size[1]; mysql_query("INSERT INTO gallery (id, path, name, ext, width, height) VALUES ('$rid', '$fname', '$extens', '$iwidth', '$iheight'"); echo '<tr title="'.$a_img[$x].'" onMouseOver="this.className=\'highlight\'" onMouseOut="this.className=\'normal\'"></td><td>'.$realimgdir.'</td><td>'.substr($a_img[$x],0, -4).'</td><td style="text-align:center;"> '.substr($a_img[$x], -3).' </td><td style="text-align:center;"> '.$size[0].' </td><td style="text-align:center;"> '.$size[1].'</td></tr>'; } ?> </table> Somebody have an idea
  9. Yeah that is what I want to do, but I dont know how to code it, can you help me on this ?
  10. Good day to you all, I'm working on a MySQL database production area. I don't yet have access to my SSH connect ion and I'm trying to not use it since it's for a project orther that my regular. I have my adding , deleting and editing script all in separate php pages. For each table that I want to be able to play with I have to rename and edit thos pages acordingly. Is there a way that I can make only a single adding, deleting and editing page work for each table in all database ? What is all the people do ?, that is the part I don't catch. Here is my pages: notes.php <?PHP //check if the starting row variable was passed in the URL or not if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) { //we give the value of the starting row to 0 because nothing was found in URL $startrow = 0; //otherwise we take the value from the URL } else { $startrow = (int)$_GET['startrow']; } mysql_connect("localhost","USER","PASSWORD");//database connection mysql_select_db("DB"); $order = mysql_query("SELECT * FROM Notes"); $num_rows = mysql_num_rows($order); // Sort Process debut $ord = (isset($_GET['ord']) && ($_GET['ord'] == 'ASC' || $_GET['ord'] == 'DESC') ? $_GET['ord'] : 'ASC'); // sets 'desc' as default $link = ($ord == 'ASC' ? 'DESC' : 'ASC'); if(empty($_GET['coll'])) { $_GET['coll'] = "priorite"; } $col = mysql_real_escape_string(trim($_GET['coll'])); // Sort Process fin //General mysql query debut $order = "SELECT * FROM Notes ORDER BY `$col` $ord LIMIT $startrow, 30"; if($order == false) { user_error(mysql_error() . "<br />\n$order"); die("SQL error"); } //General mysql query fin // Headers $result = mysql_query($order); for ($i = 0; $i < mysql_num_fields($result); $i++) { if (mysql_field_name($result, $i) == "id"){ print "<th id=\"title\" style=\"color:#FF0000;\"><a href=\"".$_SERVER['PHP_SELF']."?coll=".mysql_field_name($result, $i)."&ord=".$link."&time=".date("hisu")."\" title=\"Sort by : ".mysql_field_name($result, $i)."\" style=\"color:#000000;\">ID</a></th>\n"; }else{ print "<th id=\"title\"><a href=\"".$_SERVER['PHP_SELF']."?coll=".mysql_field_name($result, $i)."&ord=".$link."&time=".date("hisu")."\" title=\"Sort by : ".mysql_field_name($result, $i)."\"style=\"color:#000000;\">".mysql_field_name($result, $i)."</a></th>\n"; } } echo "</tr>"; // Headers fin // Form Debut echo "<tr><form method=\"post\" name=\"action\" action=\"add_row_notes.php\">"; print "<td id=\"submit\"><input type=\"submit\" id=\"envoyer\" value=\" \"></td>\n"; for ($i = 0; $i < mysql_num_fields($result); $i++) { if (mysql_field_name($result, $i) == "modif"){ print "<td id=\"submit\"><input id=\"submitt\" type=\"text\" size=\"10\" name=\"".mysql_field_name($result, $i)."\" value=\"".date('Y-m-d G:i:s')."\"></td>\n"; }else{ if (mysql_field_name($result, $i) == "note"){ print "<td id=\"submit\"><input id=\"submitt\" type=\"text\" size=\"50\" name=\"".mysql_field_name($result, $i)."\" value=\"".$_SESSION[mysql_field_name($result, $i)]."\"></td>\n"; }else{ if (mysql_field_name($result, $i) == "titre"){ print "<td id=\"submit\"><input id=\"submitt\" type=\"text\" size=\"30\" name=\"".mysql_field_name($result, $i)."\" value=\"".$_SESSION[mysql_field_name($result, $i)]."\"></td>\n"; }else{ if (mysql_field_name($result, $i) == "priorite"){ print "<td id=\"submit\"><select name=\"".mysql_field_name($result, $i)."\"><option value=\"1-Urgent\" selected>1-Urgent</option><option value=\"2-Normal\">2-Normal</option><option value=\"3-Eventuellement\">3-Eventuellement</option><option value=\"4-Autre\">4-Autre</option></select></td>\n"; }else{ if (mysql_field_name($result, $i) == "status"){ print "<td id=\"submit\"><select name=\"".mysql_field_name($result, $i)."\"><option value=\"Ouvert\" selected>Ouvert</option><option value=\"Attente_Discussion\">Attente Discussion</option><option value=\"Fermer\">Fermer</option></select></td>\n"; }else{ if (mysql_field_name($result, $i) == "categorie"){ print "<td id=\"submit\">"; print "<select name=\"".mysql_field_name($result, $i)."\">"; print "<option value=\"**-Franck\" selected>**-test</option>"; print "<option value=\"**-Rocky\" selected>**-test2</option>"; print "<option value=\"Vivants\" selected>Vivants</option>"; print "<option value=\"Inspirations\">Inspirations</option>"; print "<option value=\"Connaissances\">Connaissances</option>"; print "<option value=\"Ensemble\">Ensemble</option>"; print "<option value=\"Outils\">Outils</option>"; print "</select></td>\n"; }else{ print "<td id=\"submit\"><input id=\"submitt\" type=\"text\" size=\"1\" name=\"".mysql_field_name($result, $i)."\" value=\"".$_SESSION[mysql_field_name($result, $i)]."\"></td>\n"; } } } } } } } echo "</form></tr>"; // Headers Fin //Grid $result = mysql_query($order); $i = 1; while(($data = mysql_fetch_row($result))!== false){ $i++; if ($data[1] == ''){$data[1] = "<br>";}else{} if ($data[2] == ''){$data[2] = "<br>";}else{} if ($data[3] == ''){$data[3] = "<br>";}else{} if ($data[4] == ''){$data[4] = "<br>";}else{} if ($data[5] == ''){$data[5] = "<br>";}else{} if ($data[5] == ''){$data[6] = "<br>";}else{} if ($data[5] == ''){$data[7] = "<br>";}else{} echo("<tr style=\"border:0px;\" onMouseOver=\"this.className='highlight'\" onMouseOut=\"this.className='normal'\"> <td id=\"fields".($i & 1)."\"> <a href=\"delete_row_notes.php?id=" . $data['0'] . "\" title=\"DELETE : Row ID #:" . $data['0'] . "\"> <img src=\"Template/Images/delete.png\" border=\"0\"/></a> <a href=\"editor_row.php?id=".$data['0']."\" title=\"Edit : Row ID #:".$data['0']."\" onclick=\"load('editor_row.php?id=".$data['0']."','".$data['0']."');return false;\"> <img src=\"Template/Images/edit_icon.png\" border=\"0\"/></a> </td> <td id=\"fields".($i & 1)."\">". $data[0]."</td> <td id=\"fields".($i & 1)."\">". $data[1]."</td> <td id=\"fields".($i & 1)."\">". $data[2]."</td> <td id=\"fields".($i & 1)."\">". $data[3]."</td> <td id=\"fields".($i & 1)."\">". $data[4]."</td> <td id=\"fields".($i & 1)."\">". $data[5]."</td> <td id=\"fields".($i & 1)."\">". $data[6]."</td> </tr><tr><td colspan=\"8\" id=\"".$data['0']."\"></td></tr>"); } // Grid fin //PREV & NEXT debut echo "<tr><td colspan=\"8\" align=\"center\" id=\"listpage\">"; //only print a "Previous" link if a "Next" was clicked $prev = $startrow - 30; if ($prev >= 0) echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.$prev.'" title="Précedante ('.$prev.'/'.$startrow.')" style=\"color:#FFFFFF;\"> ('.$prev.'/'.$startrow.') Précedante</a> '; $next = $startrow+30; echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+30).'" title="Prochaine ('.$startrow.'/'.$next.')" style=\"color:#FFFFFF;\">Prochaine <font style="color:#003300">(</font>'.$startrow.'<font style="color:#003300">-</font>'.$next.'<font style="color:#003300"> / </font>'.$num_rows .'<font style="color:#003300">)</font></a>'; $prev = $startrow - 30; echo "</td></tr>"; //PREV & NEXT fin echo "</table></td></tr></table>"; ?> Add_row.php <?PHP $id = $_POST['id']; $_SESSION['id'] = $_POST['id']; $modif = $_POST['modif']; $_SESSION['modif'] = $_POST['modif']; $priorite = $_POST['priorite']; $_SESSION['priorite'] = $_POST['priorite']; $status = $_POST['status']; $_SESSION['status'] = $_POST['status']; $categorie = $_POST['categorie']; $_SESSION['categorie'] = $_POST['categorie']; $titre = $_POST['titre']; $_SESSION['titre'] = $_POST['titre']; $note = $_POST['note']; $_SESSION['note'] = $_POST['note']; mysql_connect("localhost","USER","PASSWORD");//database connection mysql_select_db("DB"); //inserting data order $order = "INSERT INTO Notes (id, modif, priorite, status, categorie, titre, note) VALUES ('NULL', '$modif', '$priorite', '$status', '$categorie', '$titre', '$note')"; //declare in the order variable $result = mysql_query($order); //order executes if($result){ echo("<br>Input data is succeed"); } else{ echo("<br>Input data is fail"); } $time = date("hisu"); ?> <script language="javascript"><!-- location.replace("Notes.php?time=<?PHP echo $time; ?>") //--> </script> I won't put my deleting and editing script, but I have added my script for adding a row to the db so you can see more of what I mean. I hope you will understand my question. Thanks !
  11. Good day to you, I have added an options to my db production site which is to back up the table into csv file, see code below. Now I would like to be able to export to sql file, how would I do it without using phpMyadmin , I would like to use a function like the following. <?php $host = 'localhost'; $user = '....'; $pass = '....'; $db = '....'; $table = $_GET[table][tr][td]; $file = 'export'; $link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error()); mysql_select_db($db) or die("Can not connect."); $result = mysql_query("SHOW COLUMNS FROM ".$table.""); $i = 0; if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $csv_output .= $row['Field']."; "; $i++; } } $csv_output .= "\n"; $values = mysql_query("SELECT * FROM ".$table.""); while ($rowr = mysql_fetch_row($values)) { for ($j=0;$j<$i;$j++) { $csv_output .= $rowr[$j]."; "; } $csv_output .= "\n"; } $filename = "Backup__".$table."__".date("Y-m-d_H-i",time()); header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv" . date("Y-m-d") . ".csv"); header( "Content-disposition: filename=".$filename.".csv"); print $csv_output; exit; echo "Exporting..."; ?> Thanks! [/td][/tr][/table]
  12. I know how to read, list files with glob, the part I don't know is how to put the result into the db, url or whole image.
  13. Good day to you all, I was looking into makeing a database of all my image and I was wondering if there is a way to read a recursive directory and store it into the database. I don't have a clue on how, even if I have search the web for a while. Thanks, take care and have a good one !
  14. yes it do. That is the part I don't understand.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.