Jump to content

html form for mysql using php


tracy

Recommended Posts

If you can do it with php you are half way there.  The html form you made should have something that looks like this

[code]<form action="phpapp.php" method="POST">[/code]
or
[code]<form action="phpapp.php" method="GET">[/code]

the action being the name of your php program that updates the database.  The method is either POST or GET what ever one you choose you will have to use the corresponding php to get the value.

$myvar = $_GET[myvar];
$myvar2 = $_POST[myvar2];

you can print these out to make sure they are working.

print ("$myvar");

Then you can edit the sql insert statement to use the values that the form sent instead of your hard coded data.

hope that helps.... I've assumed a lot so, as previous poster mentioned, posting some code might do some good.

Regards,
John Sladek

Link to comment
Share on other sites

Re-wrote, no success...
I can write the php code to post to mysql database, no problem.  That lets me know I'm connected fine to mysql.
But when I use a form (html) and send that data to insert.php on the server
for posting to mysql, it won't work.
I'm new to php, but I have written several different test pages, even allowing
phpmyadmin to help write the 'proper' insert code.  It still doesn't work. 
Absolutely nothing.  Any help is appreciated.  If you know of an easier method using a form to allow web browsers to post
to mysql database, feel free to tell me how if you know it works.
If you tell me to do something to 'test' this, please remember I'm new to php.  Thanks.

THIS IS THE FORM PAGE CODE:  (it simply has a form with two blanks:  one is make as in automobile maker, one is model, as in automobile model)

<html>
<head>
<title>Form</title>
</head>
<body>
<form action="insert.php" method="post">Make:
<input type="text" value="" name="make"> Model:
<input type="text" value="" name="model">
<input type="submit" value="Submit Query"> </form>
</body>
</html>


THIS IS THE INSERT.PHP PAGE CODE:  (CAPS JUST TO MAKE READING EASIER IN POST)

<html>
<head>
<title>Form</title>
</head>
<body>
<form action="insert.php" method="post">Make:
<input type="text" value="" name="make"> Model:
<input type="text" value="" name="model">
<input type="submit" value="Submit Query"> </form>
</body>
</html>

By the way, I have set the permissions for insert.php to 7 all the way across. 
Link to comment
Share on other sites

Tracey

I maybe wrong but in the insert.php you should just have the code that is going to insert the data into the database.


$submit = $_POST['submit'];

if($submit)

{ $make= trim($_POST['make']);
$model= trim($_POST['model']);

        //code to insert data to database.
{
Link to comment
Share on other sites

you will have say your index file.

index.php

<html>
<head>
<title>Form</title>
</head>
<body>
<form action="insert.php" method="post">Make:
<input type="text" value="" name="[color=red]make[/color]"> Model:
<input type="text" value="" name="[color=red]model[/color]">
<input type="[color=red]submit[/color]" value="Submit Query"> </form>
</body>
</html>

then the insert.php  will have the details that your are using from the form (red). 

insert.php

(database connection details)

$submit = $_POST['submit'];

if($submit)

{  $make= trim($_POST['make']);
    $model= trim($_POST['model']);
 
    mysql_query("
INSERT INTO database SET
model = '$model',
        make = '$make'
",$dbconnect)
or die(mysql_error());
{
Link to comment
Share on other sites

It looks like this will be the mysql table creation:

SQL query:CREATE TABLE `TestTable` (
`stocknumber` VARCHAR( 8 ) NOT NULL ,
`make` VARCHAR( 4 ) NOT NULL ,
`model` VARCHAR( 20 ) NOT NULL ,
`photo` VARCHAR( 30 ) NULL ,
`five` VARCHAR( 10 ) NOT NULL ,
`six` VARCHAR( 10 ) NOT NULL ,
`seven` VARCHAR( 10 ) NOT NULL ,
`eight` VARCHAR( 10 ) NOT NULL ,
PRIMARY KEY ( `stocknumber` )
) ENGINE = MYISAM ;

Keep in mind that five, six, seven and eight are simply place holders.  This entire table is just an example only.  I am interested in learning how the code works and looks for a table like this, for example.  Also, I'd like the photo to be a file, not a varchar but phpmyadmin won't allow that (at least not in a way I know)...Also:  It would be great if the photo was automatically thumbnailed.

Thanks.  If I need to start a new thread for this I will...

I checked out your site, Iobe and it is pretty cool.  Good luck with that.
Link to comment
Share on other sites

Now Were Talking...Your going to have to make two files...

Create a fill called dataConn.php and put this code in it, make sure you change the database info to your info.

[code]<?
$hostname_dataConn = "localhost";
$database_dataConn = "your_database_name";
$username_dataConn = "username";
$password_dataConn = "password";
$dataConn = mysql_pconnect($hostname_dataConn, $username_dataConn, $password_dataConn) or trigger_error(mysql_error(),E_USER_ERROR);
?>[/code]

Create a file called [b]TestTable.php[/b] and put this in it.
[code]<?
# include ("secure.php");
$pgflow = $_GET[pgflow];

# Conditional statements to determine program flow
switch ($pgflow) {

case 'addrecord':
new_record();
break;
case 'insertrecord':
insert_record();
break;
case 'deleterecord':
delete_record();
break;  
case 'editrecord':
edit_record();
break;
case 'showchanges': 
show_changes();
break;
case 'verified':
update_database();
break;
default:
show_data();
}




#-------------------------------------------------------------------------------------------------------------------------------
function delete_record(){
//get the variable datakey


//database info
include("dataConn.php");


   $stocknumber = $_GET[stocknumber];
   //print out variables so we can see if they made it
   #print ("$stocknumber <br>");
  
   $make = $_GET[make];
   //print out variables so we can see if they made it
   #print ("$make <br>");
  
   $model = $_GET[model];
   //print out variables so we can see if they made it
   #print ("$model <br>");
  
   $photo = $_GET[photo];
   //print out variables so we can see if they made it
   #print ("$photo <br>");
  
   $five = $_GET[five];
   //print out variables so we can see if they made it
   #print ("$five <br>");
  
   $six = $_GET[six];
   //print out variables so we can see if they made it
   #print ("$six <br>");
  
   $seven = $_GET[seven];
   //print out variables so we can see if they made it
   #print ("$seven <br>");
  
   $eight = $_GET[eight];
   //print out variables so we can see if they made it
   #print ("$eight <br>");
  
//connect to database
mysql_select_db($database_dataConn, $dataConn);

// create sql

$sql_delete_record ="DELETE FROM `TestTable` WHERE `stocknumber` ='$stocknumber' LIMIT 1 ; ";
#print ("$sql_delete_record");

// delete the old record if it exists
$result = mysql_query($sql_delete_record);

// close database
mysql_close();

//show records in table
show_data();

}
  
#-------------------------------------------------------------------------------------------------------------------------------
function new_record(){
  
//title of page and open table
print ("<br><br><center><h3> Add New Record in Table: TestTable</h3></center>
       <form action='".$_SERVER['PHP_SELF']."?pg=TestTable&pgflow=insertrecord' method='POST' name='log_entry'>
       <TABLE align='center' border='1'>");
print("<tr><td>stocknumber</td><td><input name='stocknumber' type='text' id='stocknumber'><img src='images/primarykey_icon.png' width='16' height='16' border='0' alt='Primary Key Feild'></td></tr>"); print("<tr><td>make</td><td><input name='make' type='text' id='make'></td></tr>"); print("<tr><td>model</td><td><input name='model' type='text' id='model'></td></tr>"); print("<tr><td>photo</td><td><input name='photo' type='text' id='photo'></td></tr>"); print("<tr><td>five</td><td><input name='five' type='text' id='five'></td></tr>"); print("<tr><td>six</td><td><input name='six' type='text' id='six'></td></tr>"); print("<tr><td>seven</td><td><input name='seven' type='text' id='seven'></td></tr>"); print("<tr><td>eight</td><td><input name='eight' type='text' id='eight'></td></tr>");   
//add submit and reset buttons
print("
       <tr>
         <td><input type='submit' name='submit' value='submit'></td>
         <td><input type='reset' name='reset' value='reset'></td>
       </tr>
       </table>
       </form>
   ");


}
  
  
#-------------------------------------------------------------------------------------------------------------------------------
function insert_record(){

include("dataConn.php");
// Variables can be declared here
  
   $stocknumber = $_POST[stocknumber];
   //print out variables so we can see if they made it
   #print ("$stocknumber <br>");
  
   $make = $_POST[make];
   //print out variables so we can see if they made it
   #print ("$make <br>");
  
   $model = $_POST[model];
   //print out variables so we can see if they made it
   #print ("$model <br>");
  
   $photo = $_POST[photo];
   //print out variables so we can see if they made it
   #print ("$photo <br>");
  
   $five = $_POST[five];
   //print out variables so we can see if they made it
   #print ("$five <br>");
  
   $six = $_POST[six];
   //print out variables so we can see if they made it
   #print ("$six <br>");
  
   $seven = $_POST[seven];
   //print out variables so we can see if they made it
   #print ("$seven <br>");
  
   $eight = $_POST[eight];
   //print out variables so we can see if they made it
   #print ("$eight <br>");
  


//connect to database
mysql_select_db($database_dataConn, $dataConn);

//create sql
$sql_insert = "INSERT INTO TestTable (stocknumber, make, model, photo, five, six, seven, eight) VALUES ('$stocknumber', '$make', '$model', '$photo', '$five', '$six', '$seven', '$eight')";

#print("$sql_insert");

// this statement actually executes the sql
$result = mysql_query($sql_insert); # make this vaiable match the last one

// close database
mysql_close();

//show records in table
show_data();

}
     
#-------------------------------------------------------------------------------------------------------------------------------
function edit_record(){

 
    // this pulls in connection specific information to connect to the database
  include ("dataConn.php");
 
   //get vars
 
   $stocknumber = $_GET[stocknumber];
   //print out variables so we can see if they made it
   #print ("$stocknumber <br>");
  
   $make = $_GET[make];
   //print out variables so we can see if they made it
   #print ("$make <br>");
  
   $model = $_GET[model];
   //print out variables so we can see if they made it
   #print ("$model <br>");
  
   $photo = $_GET[photo];
   //print out variables so we can see if they made it
   #print ("$photo <br>");
  
   $five = $_GET[five];
   //print out variables so we can see if they made it
   #print ("$five <br>");
  
   $six = $_GET[six];
   //print out variables so we can see if they made it
   #print ("$six <br>");
  
   $seven = $_GET[seven];
   //print out variables so we can see if they made it
   #print ("$seven <br>");
  
   $eight = $_GET[eight];
   //print out variables so we can see if they made it
   #print ("$eight <br>");
  
  //connect to database
  mysql_select_db($database_dataConn, $dataConn);
 
  //create sql
  #$sql_table_data="SELECT * FROM TestTable WHERE stocknumber = '$datakey'";
  $sql_table_data="SELECT * FROM TestTable WHERE `stocknumber` ='$stocknumber' LIMIT 1 ;";

  #print("$sql_table_data");
  // this statement actually executes the sql
  $result = mysql_query($sql_table_data);

  //access record info and build form
  while($row = mysql_fetch_array($result)) {

//title of page and open table
print ("<br><br><center><h3> Edit Log entry </h3></center>
       <form action='".$_SERVER['PHP_SELF']."?pg=TestTable&pgflow=showchanges' method='POST' name='log_entry'>
       <TABLE border='1'>");


  print("<tr><td>stocknumber</td><td><input name='stocknumber' type='text' id='stocknumber' value='$row[stocknumber]'><img src='images/primarykey_icon.png' width='16' height='16' border='0' alt='Primary Key Feild'>
</td></tr>");

    print("<input name='orig_stocknumber' type='hidden' id='orig_stocknumber' value='$row[stocknumber]'>");


 
  print("<tr><td>make</td><td><input name='make' type='text' id='make' value='$row[make]'></td></tr>");

    print("<input name='orig_make' type='hidden' id='orig_make' value='$row[make]'>");


 
  print("<tr><td>model</td><td><input name='model' type='text' id='model' value='$row[model]'></td></tr>");

    print("<input name='orig_model' type='hidden' id='orig_model' value='$row[model]'>");


 
  print("<tr><td>photo</td><td><input name='photo' type='text' id='photo' value='$row[photo]'></td></tr>");

    print("<input name='orig_photo' type='hidden' id='orig_photo' value='$row[photo]'>");


 
  print("<tr><td>five</td><td><input name='five' type='text' id='five' value='$row[five]'></td></tr>");

    print("<input name='orig_five' type='hidden' id='orig_five' value='$row[five]'>");


 
  print("<tr><td>six</td><td><input name='six' type='text' id='six' value='$row[six]'></td></tr>");

    print("<input name='orig_six' type='hidden' id='orig_six' value='$row[six]'>");


 
  print("<tr><td>seven</td><td><input name='seven' type='text' id='seven' value='$row[seven]'></td></tr>");

    print("<input name='orig_seven' type='hidden' id='orig_seven' value='$row[seven]'>");


 
  print("<tr><td>eight</td><td><input name='eight' type='text' id='eight' value='$row[eight]'></td></tr>");

    print("<input name='orig_eight' type='hidden' id='orig_eight' value='$row[eight]'>");


    
//add submit and reset buttons
print("
       <tr>
         <td><input type='submit' name='submit' value='submit'></td>
         <td><input type='reset' name='reset' value='reset'></td>
       </tr>
       </table>
       </form>
   ");
}

}
  
  
#-------------------------------------------------------------------------------------------------------------------------------
function show_changes(){

// Variables can be declared here

   $stocknumber = $_POST[stocknumber];
    $orig_stocknumber = $_POST[orig_stocknumber]; 
   //print out variables so we can see if they made it
   #print ("$stocknumber <br>");
   #print ("$orig_stocknumber <br>");
  
   $make = $_POST[make];
    $orig_make = $_POST[orig_make]; 
   //print out variables so we can see if they made it
   #print ("$make <br>");
   #print ("$orig_make <br>");
  
   $model = $_POST[model];
    $orig_model = $_POST[orig_model]; 
   //print out variables so we can see if they made it
   #print ("$model <br>");
   #print ("$orig_model <br>");
  
   $photo = $_POST[photo];
    $orig_photo = $_POST[orig_photo]; 
   //print out variables so we can see if they made it
   #print ("$photo <br>");
   #print ("$orig_photo <br>");
  
   $five = $_POST[five];
    $orig_five = $_POST[orig_five]; 
   //print out variables so we can see if they made it
   #print ("$five <br>");
   #print ("$orig_five <br>");
  
   $six = $_POST[six];
    $orig_six = $_POST[orig_six]; 
   //print out variables so we can see if they made it
   #print ("$six <br>");
   #print ("$orig_six <br>");
  
   $seven = $_POST[seven];
    $orig_seven = $_POST[orig_seven]; 
   //print out variables so we can see if they made it
   #print ("$seven <br>");
   #print ("$orig_seven <br>");
  
   $eight = $_POST[eight];
    $orig_eight = $_POST[orig_eight]; 
   //print out variables so we can see if they made it
   #print ("$eight <br>");
   #print ("$orig_eight <br>");
  
 
  // this pulls in connection specific information to connect to the database
  include ("dataConn.php");
 
  //connect to database
  mysql_select_db($database_dataConn, $dataConn);
 
  //create sql
  #$sql_user_data="SELECT * FROM TestTable WHERE stocknumber = '$stocknumber'";
   $sql_user_data="SELECT * FROM TestTable WHERE `stocknumber` ='$orig_stocknumber' LIMIT 1 ;";

  #print("$sql_user_data");
  // this statement actually executes the sql
  $result = mysql_query($sql_user_data);

  //access record info and build form
  while($row = mysql_fetch_array($result)) {

//title of page and open table
print ("<br><br><center><h3> Please Verify Changed below and Submit to database if correct. </h3></center>
       <form action='".$_SERVER['PHP_SELF']."?pg=TestTable&pgflow=verified' method='POST' name='log_entry'>
       <TABLE>");

  
if ($row[stocknumber]== $stocknumber) {$fontcolor = 'black';} else {$fontcolor = 'red';}
print("<tr><td><font color=$fontcolor>stocknumber</font></td><td><input name='xstocknumber' type='text' id='xstocknumber' value='$stocknumber' disabled></td></tr>");
print("<input name='stocknumber' type='hidden' id='stocknumber' value='$stocknumber'>");
print("<input name='orig_stocknumber' type='hidden' id='orig_stocknumber' value='$orig_stocknumber'>");
     
if ($row[make]== $make) {$fontcolor = 'black';} else {$fontcolor = 'red';}
print("<tr><td><font color=$fontcolor>make</font></td><td><input name='xmake' type='text' id='xmake' value='$make' disabled></td></tr>");
print("<input name='make' type='hidden' id='make' value='$make'>");
print("<input name='orig_make' type='hidden' id='orig_make' value='$orig_make'>");
     
if ($row[model]== $model) {$fontcolor = 'black';} else {$fontcolor = 'red';}
print("<tr><td><font color=$fontcolor>model</font></td><td><input name='xmodel' type='text' id='xmodel' value='$model' disabled></td></tr>");
print("<input name='model' type='hidden' id='model' value='$model'>");
print("<input name='orig_model' type='hidden' id='orig_model' value='$orig_model'>");
     
if ($row[photo]== $photo) {$fontcolor = 'black';} else {$fontcolor = 'red';}
print("<tr><td><font color=$fontcolor>photo</font></td><td><input name='xphoto' type='text' id='xphoto' value='$photo' disabled></td></tr>");
print("<input name='photo' type='hidden' id='photo' value='$photo'>");
print("<input name='orig_photo' type='hidden' id='orig_photo' value='$orig_photo'>");
     
if ($row[five]== $five) {$fontcolor = 'black';} else {$fontcolor = 'red';}
print("<tr><td><font color=$fontcolor>five</font></td><td><input name='xfive' type='text' id='xfive' value='$five' disabled></td></tr>");
print("<input name='five' type='hidden' id='five' value='$five'>");
print("<input name='orig_five' type='hidden' id='orig_five' value='$orig_five'>");
     
if ($row[six]== $six) {$fontcolor = 'black';} else {$fontcolor = 'red';}
print("<tr><td><font color=$fontcolor>six</font></td><td><input name='xsix' type='text' id='xsix' value='$six' disabled></td></tr>");
print("<input name='six' type='hidden' id='six' value='$six'>");
print("<input name='orig_six' type='hidden' id='orig_six' value='$orig_six'>");
     
if ($row[seven]== $seven) {$fontcolor = 'black';} else {$fontcolor = 'red';}
print("<tr><td><font color=$fontcolor>seven</font></td><td><input name='xseven' type='text' id='xseven' value='$seven' disabled></td></tr>");
print("<input name='seven' type='hidden' id='seven' value='$seven'>");
print("<input name='orig_seven' type='hidden' id='orig_seven' value='$orig_seven'>");
     
if ($row[eight]== $eight) {$fontcolor = 'black';} else {$fontcolor = 'red';}
print("<tr><td><font color=$fontcolor>eight</font></td><td><input name='xeight' type='text' id='xeight' value='$eight' disabled></td></tr>");
print("<input name='eight' type='hidden' id='eight' value='$eight'>");
print("<input name='orig_eight' type='hidden' id='orig_eight' value='$orig_eight'>");
     
   //add submit and reset buttons
print("
       <tr>
         <td><input type='submit' name='submit' value='submit'></td>
         <td><input type='reset' name='reset' value='reset'></td>
       </tr>
       </table>
       </form>
   ");
  
   } #end while($row = mysql_fetch_array($result))
  exit;
} #end function show_changes(){
  
#-------------------------------------------------------------------------------------------------------------------------------
function update_database(){

include("dataConn.php");
// Variables can be declared here
  
   $stocknumber = $_POST[stocknumber];
    $orig_stocknumber = $_POST[orig_stocknumber];
   //print out variables so we can see if they made it
   #print ("$stocknumber <br>");
   #print ("$orig_stocknumber <br>");
  
   $make = $_POST[make];
    $orig_make = $_POST[orig_make];
   //print out variables so we can see if they made it
   #print ("$make <br>");
   #print ("$orig_make <br>");
  
   $model = $_POST[model];
    $orig_model = $_POST[orig_model];
   //print out variables so we can see if they made it
   #print ("$model <br>");
   #print ("$orig_model <br>");
  
   $photo = $_POST[photo];
    $orig_photo = $_POST[orig_photo];
   //print out variables so we can see if they made it
   #print ("$photo <br>");
   #print ("$orig_photo <br>");
  
   $five = $_POST[five];
    $orig_five = $_POST[orig_five];
   //print out variables so we can see if they made it
   #print ("$five <br>");
   #print ("$orig_five <br>");
  
   $six = $_POST[six];
    $orig_six = $_POST[orig_six];
   //print out variables so we can see if they made it
   #print ("$six <br>");
   #print ("$orig_six <br>");
  
   $seven = $_POST[seven];
    $orig_seven = $_POST[orig_seven];
   //print out variables so we can see if they made it
   #print ("$seven <br>");
   #print ("$orig_seven <br>");
  
   $eight = $_POST[eight];
    $orig_eight = $_POST[orig_eight];
   //print out variables so we can see if they made it
   #print ("$eight <br>");
   #print ("$orig_eight <br>");
  


//connect to database
mysql_select_db($database_dataConn, $dataConn);

//create sql
#$sql_update="UPDATE `TestTable` SET `stocknumber` = '$stocknumber',`make` = '$make',`model` = '$model',`photo` = '$photo',`five` = '$five',`six` = '$six',`seven` = '$seven',`eight` = '$eight' WHERE `stocknumber` =$stocknumber LIMIT 1";
#$sql_update="UPDATE `TestTable` SET `stocknumber` = '$stocknumber',`make` = '$make',`model` = '$model',`photo` = '$photo',`five` = '$five',`six` = '$six',`seven` = '$seven',`eight` = '$eight' WHERE `stocknumber` ='$stocknumber' LIMIT 1 ;";
$sql_update="UPDATE `TestTable` SET `stocknumber` = '$stocknumber',`make` = '$make',`model` = '$model',`photo` = '$photo',`five` = '$five',`six` = '$six',`seven` = '$seven',`eight` = '$eight' WHERE `stocknumber` ='$orig_stocknumber' LIMIT 1 ;";
#print("$sql_update");

// this statement actually executes the sql
$result = mysql_query($sql_update); # make this vaiable match the last one

// close database
mysql_close();

//show records in table
show_data();
  exit;
}
  
function show_data(){

  // Title of page
  print "<center><h3>TestTable</h3></center>";
 
  // this pulls in connection specific information to connect to the database
  include ("dataConn.php");
 
  //connect to database
  mysql_select_db($database_dataConn, $dataConn);
 
  //create sql
  $sql_user_data="SELECT * FROM TestTable";

  // this statement actually executes the sql
  $result = mysql_query($sql_user_data);
 
  //Create table
  print("<table border='1' align='center'><tr>");
 
  //add edit column header
  print("<th>Edit");
 
    //create column headers based on feilds from table
print("<th>stocknumber");
print("<th>make");
print("<th>model");
print("<th>photo");
print("<th>five");
print("<th>six");
print("<th>seven");
print("<th>eight");

// add the delete column header
  print("<th>Delete</tr>");

  //now we iterate through the results of the SQL Query
  while($row = mysql_fetch_array($result)) {
  //create a new row in the table
  print("<tr>");
 
  // add an edit icon for the row

  #print("<td align='center'><a href='".$_SERVER['PHP_SELF']."?pg=TestTable&pgflow=editrecord&datakey=$row[stocknumber]'><img src='images/edit_icon.png' width='16' height='16' border='0' alt='edit'></a></td>");
  print("<td align='center'><a href='".$_SERVER['PHP_SELF']."?pg=TestTable&pgflow=editrecord&stocknumber=$row[stocknumber]'><img src='images/edit_icon.png' width='16' height='16' border='0' alt='edit'></a></td>");

print("<td>$row[stocknumber]&nbsp;</td>");
print("<td>$row[make]&nbsp;</td>");
print("<td>$row[model]&nbsp;</td>");
print("<td>$row[photo]&nbsp;</td>");
print("<td>$row[five]&nbsp;</td>");
print("<td>$row[six]&nbsp;</td>");
print("<td>$row[seven]&nbsp;</td>");
print("<td>$row[eight]&nbsp;</td>");

  // add a delete icon for the row
  #print("<td align='center'><a href='".$_SERVER['PHP_SELF']."?pg=TestTable&pgflow=deleterecord&datakey=$row[stocknumber]'><img src='images/delete_icon.png' width='16' height='16' border='0' alt='edit'></a></td>");
  print("<td align='center'><a href='".$_SERVER['PHP_SELF']."?pg=TestTable&pgflow=deleterecord&stocknumber=$row[stocknumber]'><img src='images/delete_icon.png' width='16' height='16' border='0' alt='edit'></a></td>");

  print("</tr>");
  } #end while( = mysql_fetch_array())
 
    // add a final row to the end of the table that has a link to add a record
  print("<tr><td align='right'><a href='".$_SERVER['PHP_SELF']."?pg=TestTable&pgflow=addrecord'>New Record</a><td></tr>");
 
  // finally we close the table
  print("</table>");


}
?>[/code]

Let me know how it works for you...

-John Sladek

PS. Here are the images that are missing, just save them in a directory called image, much like you see them.
http://www.iobe.net/proj/images/edit_icon.png
http://www.iobe.net/proj/images/delete_icon.png
http://www.iobe.net/proj/images/primarykey_icon.png
http://www.iobe.net/proj/images/autoincrement_icon.png

Link to comment
Share on other sites

John-

Sorry for the late reply.  I appreciate the effort.

I think maybe I'm missing something.  Are these files supposed to be linked from somewhere, like a delete button or add/edit button?  Kinda new to this, so sorry...

I can't get it to work.  When I open these php files (dataConn.php or testtable.php) the browser shows a blank page.  I entered some test data in mysql but still blank pages.

I also don't understand the picture part.  The last entry of yours about the SRC file...

Thanks.
Link to comment
Share on other sites

Hi Just upload both those pages to your server that is running php make sure they are in the same directory. the dataConn.php you will have to edit and put in the connection information specific to your database.

Change this stuff...

$hostname_dataConn = "localhost";
$database_dataConn = "your_database_name";
$username_dataConn = "username";
$password_dataConn = "password";

The link to the images are so you have them.  The script will run without having them it will just be missing images. 

I'd like to see you get this working so let me know.

-John

Link to comment
Share on other sites

Thanks. 

I have one other question, related to this.  When I output this table to the browser, I'm finding it hard to get a good tutorial or instructions on making one of the columns a check box.  That way, if the box is checked and the delete or edit button is clicked, that file that is checked will be opened for editing or deleted, whichever is the case. 

I think I know the premise of it, but the actual writing of the exact phrase to get the true/false statement from the checkbox cell is the problem for me.  Any thoughts on where I can get this info?  I'm not asking for you to write it for me, just the info.  Thanks for all your help.  It is appreciated.

Link to comment
Share on other sites

Yes, it was auto generated based on the sql you provided me with.  I used a program I wrote to create that file.  It basically asks for infomation to log into your database and then creates a php script like that for each table in your database.  The program can be downloaded free if your interested, http://www.iobe.net/proj/ .  

There are a bunch of things that that script does not do (it's a work in progress) but it is a quick way to get started, especially if you have a lot of tables in your database.  One of the good things about it is it should be pretty easy to go into and see what is going on.

Regards,
John Sladek
Link to comment
Share on other sites

Hi, Sorry it's not working for you.  I've only had a few servers to test it on. I'm suprised that you are not getting a blank page and no errors.  What do you get when you do a view source of the webpage?  I'd like to help you get this working, it's kinda like test and tune for my program.

Regards,
John Sladek

AIM: johnnysladek
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.