473,769 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with formatting and editing a php script

Hi All,

I have struggled through this far with help from many of you so thanks. I am
stuck again. I am really new to this so don't be harsh :-)

There are a few problems. You can run the script here
http://www.pbrown.com/research/test1.php to see the formatting issues

Formatting Issues

1) Why do I get the extra '(' before the '(delete) link
2) Why does the 4th (and I think it is always the last rather than being
just the 4th) record always show below the Add Record link?
Editing Problem

1) When I actually select to delete a record it doesn't, I think it is
related to an 'id' issue but can't see where
2) When I click a link to edit it, it doesn't populate the form below...Why?

I know I am asking a lot. Thanks for any help indeed. If you are asking me
to put any code in to test please help me by being specific

Cheers

Paul

<html><style type="text/css">
<!--
body,td,th {
color: #CCCCCC;
}
body {
background-color: #000000;
}
a:link {
color: #CCCCCC;
}
a:visited {
color: #CCCCCC;
}
a:hover {
color: #CCCCCC;
}
a:active {
color: #CCCCCC;
}
..style1 {
font-size: x-small;
font-style: italic;
}
-->
</style>
<body>
<div align="left">
<p align="center"> <img src="/cpsheadersm.jpg " width="409"
height="110"></p>
<p> <?php

$db = mysql_connect(" localhost", "user", "password") ;
mysql_select_db ("reminders",$d b);

if ($submit) {
// here if no ID then adding else we're editing
if ($id) {
$sql = "UPDATE research_main SET
date_event='$da te_event',info_ research='$info _research',medi um_name='$mediu m
_name',place_na me='$place_name ',date_invest=' $date_invest',v erified_event=' $
verified_event' ,closed_event=' $closed_event' WHERE id=$id";
} else {
$sql = "INSERT INTO research_main
(date_event,inf o_research,medi um_name,place_n ame,date_invest ,verified_event ,
closed_event) VALUES
('$date_event', '$info_research ','$medium_name ','$place_name' ,'$date_invest' ,
'$verified_even t','$closed_eve nt')";
}
// run SQL against the DB
$result = mysql_query($sq l);
echo "Record updated/edited!<p>";
} elseif ($delete) {
// delete a record
$sql = "DELETE FROM research_main WHERE id=$id";
$result = mysql_query($sq l);
echo "$sql Record deleted!<p>";
} else {
// this part happens if we don't press submit
if (!$id) {
// print the list if there is not editing

$result = mysql_query("SE LECT * FROM research_main", $db);
while ($myrow = mysql_fetch_arr ay($result)) {

echo "<table border=2>\n";
echo "<tr><td> Investigation Date </td><td> Research Information
</tr><td> Mediums Name </tr><td> Location </tr><td> date being
Researched </tr>\n";

printf("(<a href=\"%s?id=%s \"><tr><td>% s</td><td> %s
</td><td>%s</td></tr></a> \n", $PHP_SELF, $myrow["id"],
$myrow["date_event "], $myrow["info_resea rch"], $myrow["medium_nam e"],
$myrow["place_name "], $myrow["date_inves t"], $myrow["verified_event "],
$myrow["closed_eve nt"]);

printf("<a href=\"%s?id=%s &delete=yes\">( DELETE)</a><br>", $PHP_SELF,
$myrow["id"]);

}

}

?>

</p>
</div>
<p>&nbsp;</p>
<P>

<a href="<?php echo $PHP_SELF?>">AD D A RECORD</a>

<P>

<form method="post" action="<?php echo $PHP_SELF?>">

<?php

if ($id) {

// editing so select a record

$sql = "SELECT * FROM research_main WHERE id=$id";

$result = mysql_query($sq l);

$myrow = mysql_fetch_arr ay($result);

$id = $myrow["id"];

$date_event = $myrow["date_event "];

$info_research = $myrow["info_resea rch"];

$medium_name = $myrow["medium_nam e"];

$place_name = $myrow["place_name "];

$date_invest = $myrow["date_inves t"];

$verified_event = $myrow["verified_event "];

$closed_event = $myrow["closed_eve nt"];

// print the id for editing

?>

<p>
<input type=hidden name="id" value="<?php echo $id ?>">

<?php

}

?>
</p>
<table width="803" border="0">
<tr>
<td width="284">&nb sp;</td>
<td width="509">&nb sp;</td>
</tr>
<tr>
<td>Date Of Event: <span class="style1"> yyyy-mm-dd</span> </td>
<td><input name="date_even t" type="Text" value="<?php echo
$date_event ?>" size="10"></td>
</tr>
<tr>
<td valign="top">Re search Details</td>
<td bordercolor="#0 00000"><textare a name="info_rese arch"
rows="10"><?php echo $info_research ?></textarea></td>
</tr>
<tr>
<td valign="top">Na me of Medium or Researcher:</td>
<td bordercolor="#0 00000"><input name="medium_na me" type="Text"
id="medium_name 2" value="<?php echo $medium_name ?>" maxlength="30"> </td>
</tr>
<tr>
<td valign="top">In vestigation Location:</td>
<td bordercolor="#0 00000"><input name="place_nam e" type="Text"
id="place_name3 " value="<?php echo $place_name ?>" maxlength="50"> </td>
</tr>
<tr>
<td valign="top">Da te to be researched: <span
class="style1"> yyyy-mm-dd</span> </td>
<td bordercolor="#0 00000"><input name="date_inve st" type="Text"
id="date_invest " value="<?php echo $date_death ?>" size="10"></td>
</tr>
<tr>
<td valign="top">Re search Verified:</td>
<td bordercolor="#0 00000"><input name="verified_ event" type="radio"
value="Yes">
YES
<input name="verified_ event" type="radio" value="No" checked>
NO</td>
</tr>
<tr>
<td valign="top">Re search Closed:</td>
<td bordercolor="#0 00000"><input name="closed_ev ent" type="radio"
value="Yes">
YES
<input name="closed_ev ent" type="radio" value="No" checked>
NO</td>
</tr>
</table>
<p>
<input type="Submit" name="submit" value="Enter information">
</p>
</form>

<?php

}

?>

</body>

</html>

Jul 17 '05 #1
4 2402
> Formatting Issues

1) Why do I get the extra '(' before the '(delete) link
2) Why does the 4th (and I think it is always the last rather than being
just the 4th) record always show below the Add Record link?
Editing Problem

1) When I actually select to delete a record it doesn't, I think it is
related to an 'id' issue but can't see where
2) When I click a link to edit it, it doesn't populate the form below...Why?

I know I am asking a lot. Thanks for any help indeed. If you are asking me
to put any code in to test please help me by being specific

Cheers

Paul


Hi Paul,

Don't know if anyone else, but I'm too lazy to read all your code and
to search the relevant lines. Could you please post only the relevant
code lines here?
thx.

Greetz
Paul.
Jul 17 '05 #2

"Paul 'piz' Wellner Bou" <pa**********@u nited-scripts.com> wrote in message
news:c0******** *****@ID-205474.news.uni-berlin.de...
Formatting Issues

1) Why do I get the extra '(' before the '(delete) link
2) Why does the 4th (and I think it is always the last rather than being
just the 4th) record always show below the Add Record link?
Editing Problem

1) When I actually select to delete a record it doesn't, I think it is
related to an 'id' issue but can't see where
2) When I click a link to edit it, it doesn't populate the form below...Why?
I know I am asking a lot. Thanks for any help indeed. If you are asking me to put any code in to test please help me by being specific

Cheers

Paul


Hi Paul,

Don't know if anyone else, but I'm too lazy to read all your code and
to search the relevant lines. Could you please post only the relevant
code lines here?
thx.

H Paul,

I will try but as i said I really have no idea where it is going wrong so I
thought I would try and give as much as poss.

if ($submit) {
// here if no ID then adding else we're editing
if ($id) {
$sql = "UPDATE research_main SET
date_event='$da te_event',info_ research='$info _research',medi um_name='$mediu m
_name',place_na me='$place_name ',date_invest=' $date_invest',v erified_event=' $
verified_event' ,closed_event=' $closed_event' WHERE id=$id";
} else {
$sql = "INSERT INTO research_main
(date_event,inf o_research,medi um_name,place_n ame,date_invest ,verified_event ,
closed_event) VALUES
('$date_event', '$info_research ','$medium_name ','$place_name' ,'$date_invest' ,
'$verified_even t','$closed_eve nt')";
}
// run SQL against the DB
$result = mysql_query($sq l);
echo "Record updated/edited!<p>";
} elseif ($delete) {
// delete a record
$sql = "DELETE FROM research_main WHERE id=$id";
$result = mysql_query($sq l);
echo "$sql Record deleted!<p>";
} else {
// this part happens if we don't press submit
if (!$id) {
// print the list if there is not editing

$result = mysql_query("SE LECT * FROM research_main", $db);
while ($myrow = mysql_fetch_arr ay($result)) {

echo "<table border=2>\n";
echo "<tr><td> Investigation Date </td><td> Research Information
</tr><td> Mediums Name </tr><td> Location </tr><td> date being
Researched </tr>\n";

printf("(<a href=\"%s?id=%s \"><tr><td>% s</td><td> %s
</td><td>%s</td></tr></a> \n", $PHP_SELF, $myrow["id"],
$myrow["date_event "], $myrow["info_resea rch"], $myrow["medium_nam e"],
$myrow["place_name "], $myrow["date_inves t"], $myrow["verified_event "],
$myrow["closed_eve nt"]);

printf("<a href=\"%s?id=%s &delete=yes\">( DELETE)</a><br>", $PHP_SELF,
$myrow["id"]);

}

}

?>

</p>
</div>
<p>&nbsp;</p>
<P>

<a href="<?php echo $PHP_SELF?>">AD D A RECORD</a>

<P>

<form method="post" action="<?php echo $PHP_SELF?>">

<?php

if ($id) {

// editing so select a record

$sql = "SELECT * FROM research_main WHERE id=$id";

$result = mysql_query($sq l);

$myrow = mysql_fetch_arr ay($result);

$id = $myrow["id"];

$date_event = $myrow["date_event "];

$info_research = $myrow["info_resea rch"];

$medium_name = $myrow["medium_nam e"];

$place_name = $myrow["place_name "];

$date_invest = $myrow["date_inves t"];

$verified_event = $myrow["verified_event "];

$closed_event = $myrow["closed_eve nt"];

// print the id for editing

?>

<p>
<input type=hidden name="id" value="<?php echo $id ?>">

<?php

}

?>
Jul 17 '05 #3
Dan Weeb wrote:
Hi All,

I have struggled through this far with help from many of you so thanks. I am
stuck again. I am really new to this so don't be harsh :-)

There are a few problems. You can run the script here
http://www.pbrown.com/research/test1.php to see the formatting issues

Formatting Issues

1) Why do I get the extra '(' before the '(delete) link
2) Why does the 4th (and I think it is always the last rather than being
just the 4th) record always show below the Add Record link?
Editing Problem

1) When I actually select to delete a record it doesn't, I think it is
related to an 'id' issue but can't see where
2) When I click a link to edit it, it doesn't populate the form below...Why?

I know I am asking a lot. Thanks for any help indeed. If you are asking me
to put any code in to test please help me by being specific

Cheers

Paul


I also don't have time to trudge through all the code, however I did
have a quick look and I saw
printf("(<a href=\"%s?id=%s \"><tr><td>% s</td><td> %s
</td><td>%s</td></tr></a> \n", $PHP_SELF, $myrow["id"],
$myrow["date_event "], $myrow["info_resea rch"], $myrow["medium_nam e"],
$myrow["place_name "], $myrow["date_inves t"], $myrow["verified_event "],
$myrow["closed_eve nt"]);
Note the printf("(<a href=\.... on the first line, could this be your
extra (?

~Cameron

Jul 17 '05 #4
I noticed that Message-ID: <c0************ *******@news.de mon.co.uk> from
Dan Weeb contained the following:
Hi All,

I have struggled through this far with help from many of you so thanks. I am
stuck again. I am really new to this so don't be harsh :-)

There are a few problems. You can run the script here
http://www.pbrown.com/research/test1.php to see the formatting issues

Formatting Issues

1) Why do I get the extra '(' before the '(delete) link You have an extra bracket in the printf
2) Why does the 4th (and I think it is always the last rather than being
just the 4th) record always show below the Add Record link?


Try organising your code better, then you can see where the errors are.
There are missing tags. I'd do it like this (BTW I recognise the
tutorial...:-)

There are lots of mistakes with both formatting and dispaying your data.
Forinstance in your prinf() you had $myrow["verified_event "],
$myrow["closed_eve nt"]with no place in your table to put them.

I assume you only need the header row once and that you did intend to
put a </table> tag in somewhere.

Try this for the while() loop (untested)

echo "<table border=2>\n";
echo "<tr>
<td> Investigation Date </td>
<td> Research Information </tr>
<td> Mediums Name </tr>
<td> Location </tr>
<td> date being Researched </td>
<td> Delete </tr>
</tr>\n";

while ($myrow = mysql_fetch_arr ay($result)) {
printf("<tr>
<td><a href=\"%s?id=%s \">%s</a></td>
<td> %s </td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td><a href=\"%s?id=%s &delete=yes\">( DELETE)</a>"</td>
</tr> \n",
$PHP_SELF,$myro w["id"],$myrow["date_inves t"],$myrow["info_resea rch"],
$myrow["medium_nam e"],$myrow["place_name "],
$myrow["date_event "],$PHP_SELF,$myr ow["id"]);
}
echo "</table>";
Editing Problem

1) When I actually select to delete a record it doesn't, I think it is
related to an 'id' issue but can't see where
You should have a field in that database called 'id' it should be the
primary key and should be set as INT and be auto_increment.

Have you? Because the query is not returning a result for this field.
Try doing this instead.
// delete a record
$sql = "DELETE FROM research_main WHERE id=$id";
if(mysql_query( $sql)){
echo "$sql Record deleted!";}
else{ echo "Could not delete record";}

This is a very bad way of deleting records by the way. If this page is
indexed by search engines it will delete all your records. However,
let's get it working first eh?

2) When I click a link to edit it, it doesn't populate the form below...Why?


Missing id so it can't find the record. You need to fix that first then
we'll look at that.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2441
by: Colin J. Williams | last post by:
PythonWin has been my favourite IDE for quite a while. When one right clicks on a .py file in the Windows Explorer, among the options are Open and Edit. The former is the default and executes Python, with the selected script. The latter activates the PythonWin editor, with the selected script. Since, most frequently, I wish to edit the script, or execute it with the debugger, I tried changing the default to Edit, using the Edit File...
26
2677
by: jamesbeswick | last post by:
I've been using Access since version 97 and I've migrated to 2003. I've noticed a substantial number of strange ActiveX/OLE and code corruption problems when writing databases. The only solution I've found is to create a new database and import all the objects from the corrupted file. Has anyone else found a solution to this annoying problem? I cannot find anything useful on Microsoft's website and I haven't seen any posts about the...
2
1449
by: Rick Strahl [MVP] | last post by:
I seem to have problems when working with large Windows Forms files. What happens is that hte editor looses its syntax color highlighting and Intellisense capability on large files. The code works - it compiles and runs fine, but the syntax color highlighting goes away. All formatting blows up too and the editor no longer helps with indentations. Needless to say this is frustrating. If I recompile then color returns but as soon as I...
5
1102
by: Lloyd Sheen | last post by:
I have been adding client code manually but upon reading some of the docs I notice that I should be able to create the stub for events in client script using the IDE menus. Now this would save time (something an IDE is supposed to do), but like way too many things in the VS 2003 IDE it will not work. I followed the instructions (ms-help://MS.VSCC.2003/MS.MSDNQTR.2004JAN.1033/vsintro7/html/csconCreatingS criptsInHTMLEditor.htm) but the...
0
1082
by: Jimmy Tharpe | last post by:
Hi, I am having trouble editing the code-behind files of ASP.NET applications in Visual Studio .NET. I often lose syntax highlighting, code formatting, and intelisense. Occasionally, I lose "random" characters from my code file. This makes editing code-behind files extremely difficult. I have uninstalled all 3rd party tools andcompletly removed then re-installed VS.NET, but the problems still occur.
2
5393
by: goodnamesalltaken | last post by:
Hello fellow python users, I've been working on a basic implementation of a privilege separated web server, and I've goto the point of running a basic cgi script. Basically when the execCGI function in my Unpriv.py program is called a few things should happen, it should fork (which it does), the stdout of the child should be redirected to a given pipe (which it does), and the script should execute using execve(which is has problems...
1
1872
by: AmitKu | last post by:
I've got the Gridview going at full speed, and I've enabled editing, but when I click on the "edit" button, this ugly editing UI comes up. Well it's not ugly, but it's not great either. How do I change the font/font size of the text thats being edited? Thanks in advance, Amit
5
4188
by: jp2code | last post by:
I have a website hosted on GoDaddy.com. To process forms, GoDaddy requires users to use their gdform script. (My copy of) The script is here: http://www.joeswelding.biz/gdform.asp I use this script to receive email messages, but the formatting of them is horrible.
6
4607
by: Tomasz J | last post by:
Hello developers, I bind my TextBox control specyfying a format stored in my application global ApplicationContext object - it has a static string CurrencyFormat property. The problem - this works fine: Text='<%# Eval("Price", ApplicationContext.CurrencyFormat) %>'
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10210
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5297
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5445
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3955
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3560
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.