HI Kevin,
you are the first Irish person I have seen on this list!!
Anyhow, When you submit the form insure that the form submits to itself so
you don't have to worry about a refresh. On the top of the page have the
form and below do the select statement to show what is in the table. When
the form is submitted to itself it will run the select statement again and
show the latest data.
Here is some code for a complete page that can be seen at
http://www.navanwebdesign.com/php/admin/index.php
Please feel free to mess around with it. I am a beginner too so to get a
file that does all can be so helpful. However because I am a beginner this
may not be the most effective way of doing it.
All the Best
Lisa
<?
$host="";
$user="";
$password="";
$dbasename="";
mysql_pconnect("$host","$user","$password")
or die("Unable to connect to SQL server");
mysql_select_db("$dbasename") or die("Unable to select database");
if ($delete) {
// delete a record
$sql1 = "DELETE FROM pages WHERE page_id=$page_id";
$result = mysql_query($sql1);
$query="DELETE FROM page_creation WHERE page_id=$page_id";
$result = MYSQL_QUERY($query) OR die("There was an error!") ;
}
if ($edit) {
// delete a record
$sql1 = "SELECT FROM page_creation WHERE page_id=$page_id";
$result = mysql_query($sql1);
}
if ($submit) {
$sql1 = "INSERT INTO page_creation values(NULL,'$page_name')";
$result = mysql_query($sql1);
$query="select LAST_INSERT_ID() as page_id ";
$result = MYSQL_QUERY($query) OR die("There was an error!") ;
while($row = mysql_fetch_array($result)) {
$page_id=$row["page_id"];
}
$sql2 = "INSERT INTO pages
(pg_id,page_id,pg_auction_title,pg_auction_date,pg_cat_no,pg_desc,pg_img_url
,pg_price)
values(NULL,'$page_id','$pg_auction_title','$pg_auction_date','$pg_cat_no','
" . str_replace("\n","<br>", $pg_desc) . "','$pg_img_url','$pg_price')";
$result2 = mysql_query($sql2);
}
?>
<HTML>
<HEAD>
<SCRIPT>
if (navigator.appName == "Netscape") {
StyleSheet = "netstyle.css"
} else {
StyleSheet = "iestyle.css"
}
</SCRIPT>
<SCRIPT>document.write('<link rel=stylesheet type="text/css" href="'
+StyleSheet + '">')</SCRIPT>
<TITLE>Add a Message</TITLE>
</HEAD>
<SCRIPT>
if (navigator.appName == "Netscape") {
StyleSheet = "netstyle.css"
} else {
StyleSheet = "iestyle.css"
}
</SCRIPT>
<SCRIPT>document.write('<link rel=stylesheet type="text/css" href="'
+StyleSheet + '">')</SCRIPT>
<BODY BGCOLOR="#FFFFFF" topmargin=0 leftmargin=0>
<form method="post" action="<?php echo $PHP_SELF?>">
<TABLE WIDTH=700 CELLPADDING=0 CELLSPACING=0 BORDER=1
BORDERCOLOR="#C0C0C0">
<TR><TD WIDTH=350 CLASS="content" VALIGN=TOP>
<input type=hidden name="id" value="<?php echo $id ?>">
<FONT CLASS="header">Add a New Web Page
<TABLE WIDTH=350 CELLPADDING=0 CELLSPACING=0 BORDER=1 BORDERCOLOR="#C0C0C0">
<TR><TD WIDTH=100 CLASS="label">Auction Page Name</TD>
<TD WIDTH=250 CLASS="label"><input type="Text" name="page_name"
value="<?php echo $page_name ?>" CLASS="box"></TD>
</TR>
<TR><TD WIDTH=100 CLASS="label">Auction Title</TD>
<TD WIDTH=250 CLASS="label"><input type="Text"
name="pg_auction_title" value="<?php echo $pg_auction_title ?>"
CLASS="box"></TD>
</TR>
<TR><TD WIDTH=100 CLASS="label">Auction Date</TD>
<TD WIDTH=250 CLASS="label"><input type="Text"
name="pg_auction_date" value="<?php echo $pg_auction_date ?>"
CLASS="box"></TD>
</TR>
<TR><TD WIDTH=100 CLASS="label">Catologue Number</TD>
<TD WIDTH=250 CLASS="label"><input type="Text" name="pg_cat_no"
value="<?php echo $pg_cat_no ?>" CLASS="box"></TD>
</TR>
<TR><TD WIDTH=100 CLASS="label">Catalog Entry Description</TD>
<TD WIDTH=250 CLASS="label"><TEXTAREA name="pg_desc" COLS=30
ROWS=3><?php echo $pg_desc ?></TEXTAREA></TD>
</TR>
<TR><TD WIDTH=100 CLASS="label">Catalog Entry Image URL</TD>
<TD WIDTH=250 CLASS="label"><input type="Text" name="pg_img_url"
value="<?php echo $pg_img_url ?>" CLASS="box"></TD>
</TR>
<TR><TD WIDTH=100 CLASS="label">Catalog Entry Price</TD>
<TD WIDTH=250 CLASS="label"><input type="Text" name="pg_price"
value="<?php echo $pg_price ?>" CLASS="box"></TD>
</TR>
<TR><TD COLSPAN=2 CLASS="label"><CENTER><input type="Submit" name="submit"
value="Enter information" CLASS="box"></TD>
</TR>
</TABLE>
</form>
</TD>
<TD WIDTH=350 CLASS="content" VALIGN=TOP>
<FONT CLASS="header">Edit Web Page
<TABLE WIDTH=350 CELLPADDING=0 CELLSPACING=0 BORDER=1 BORDERCOLOR="#C0C0C0">
<TR><TD WIDTH=200 CLASS="label">Edit Auction Page</TD>
<TD WIDTH=75 CLASS="label">Edit page Title</TD>
<TD WIDTH=75 CLASS="label">Delete page Title</TD>
</TR>
<TABLE WIDTH=100% BORDER=1>
<? // editing so select a record
$sql = "SELECT * FROM page_creation";
$result=mysql_query($sql);
//$myrow=mysql_fetch_array($result);
$page_id=$myrow["page_id"];
$page_name=$myrow["page_name"];
while ($myrow = mysql_fetch_array($result)) {
?>
<TR>
<TD CLASS="content"><A CLASS="content" HREF="show_pg.php?page_id=<?echo
$myrow["page_id"];?>" TARGET="bottom"><?echo $myrow["page_name"];?></A> -
Show All listing for that 1 page</TD>
<TD CLASS="content"><A CLASS="content" HREF="edit_title.php?page_id=<?echo
$myrow["page_id"];?>&edit=yes" TARGET="bottom">EDIT</A></TD>
<TD CLASS="content"><A CLASS="content" HREF="index.php?page_id=<?echo
$myrow["page_id"];?>&delete=yes">DELETE</A></TD>
</TR>
<?}?>
</TABLE>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
-----Original Message-----
From: Kevin Connolly [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 26, 2001 3:44 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] continuously view database updates.
Hi,
I am doing a college project which involves using PHP scripts to update a
MySQL database. For demonstration purposes I would like the new updated
table in my Database to be shown each time it is updates without me having
to go to the command prompt window and type in select * from members; for
example! I will have the command window open for the demo.
Thanks
Kev.