TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-30-2010, 02:24 AM   #1 (permalink)
The Acquainted
 
Peuplarchie's Avatar
 
Join Date: May 2008
Location: Québec
Posts: 104
Thanks: 10
Peuplarchie is on a distinguished road
Application Add, delete, edit page working for each table automaticly

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 Code:
      
<?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=\"&nbsp;&nbsp;&nbsp;\"></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&eacute;cedante ('.$prev.'/'.$startrow.')" style=\"color:#FFFFFF;\"> ('.$prev.'/'.$startrow.') Pr&eacute;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 Code:


<?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 !
__________________
That's why we are not alone on earth... let's build !
Peuplarchie is offline  
Reply With Quote
Old 10-22-2012, 08:28 AM   #2 (permalink)
The Addict
 
Join Date: Oct 2012
Posts: 244
Thanks: 0
dashixiong is on a distinguished road
Default Coach Outlet

You’ve relativelyCoach Outlet recently arrived in New Delhi after living in two of Asia’s other great cities,Coach Outlet Store Online Tokyo and Hong Kong, for several years. Do these cities feel like they’re part of the same continent? Yes, and no. In terms Coach Factory Onlineof infrastructure, they couldn’t be more different. Getting regularCoach Outlet power and water at my house in New Delhi is never a sure thing, even though Coach Purse Outlet OnlineI’m paying the same rent that I paid in Tokyo and almost the same electricity prices. Both Hong Kong and Tokyo are also crowded places,Coach Factory Outlet Online but both cities are incredibly well planned and efficiently run. Efficient is not a word I would use to describe my Coach Bags Outlet Onlineday-to-day life in New Delhi. On the other hand, one thing that I think Hong Kong and New Delhi have in common isCoach Handbags Outlet a shared sense of optimism — a feeling that the best is yet to come. That’s definitely not the feeling you get in Tokyo,Coach Outlet Online or in the U.S. when I go home. It’s a big part of what I find addictive about living and working in this part of the world. You feel like you’re watching the future unfold.
dashixiong is offline  
Reply With Quote
Old 11-13-2012, 11:29 AM   #3 (permalink)
The Addict
 
Join Date: Nov 2012
Posts: 331
Thanks: 0
shui1880 is on a distinguished road
Default

If you are a music enthusiast longing to listen to your favorite music for extended periods of time, Monster headphones fit the bill perfectly. They have been designed to ensure a thrilling music experience for extended periods without causing discomfort or pain to the user. An interesting feature of Dr Dre Headphones the Monster Beats is that you don need to dig into your pocket to pause or press mute. A quick tap is what it takes to do the needful. You can choose from a variety of eye-catching accessories to complement dr dre beats these headphones. Browse the web to navigate an exotic range of stunning accessories online. They are http://www.drdreheadphones-sale.net available at astonishingly competitive prices.
shui1880 is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a gallery class Tanax Advanced PHP Programming 25 02-19-2013 04:25 AM
feedback on my class please frostyboy33 Advanced PHP Programming 7 10-22-2012 09:12 AM
help on making my own crawler webtuto General 16 08-08-2009 08:55 AM
Databse structure Village Idiot TalkPHP Developer Team 3 01-16-2009 10:31 PM
This project has begun! Village Idiot TalkPHP Developer Team 40 01-01-2009 04:29 AM


All times are GMT. The time now is 12:42 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design