Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newsletter Content

Status
Not open for further replies.

pastorandy

IS-IT--Management
Nov 2, 2006
84
GB
I have a newsletter which has about 20 dynamic pieces of content that come from a mySql database. One of the fields in my newsletter table is called test_field.

I am just creating this application at the moment but have got to the stage where I want to be able to edit each part of the newsletter.

What I am trying to do is click on a link or a button - next to the content that I want to edit within the newsletter but I want to be able to use one form page to edit and then update that content.

I don't want to bring all the content of the newsletter into my edit form - just the piece that I want to edit.

My first thought was to do something like this in the newsletter:
Code:
<a href='editNews.php?newsletter_id=$row[newsletter_id]&form_field=test_field'><img src='./img/edit.gif' border='0'></a>";

This would send me to my edit page and pass the newsletter table field (test_field) that I want to use in my edit form.

Then on my editNews.php page I would have something like this:
Code:
$form_field    = $_GET['form_field'];
$query2 = "SELECT * from newsletter WHERE newsletter_id = $newsletter_id
           ";
		   
$result2 = mysql_query($query2) or die (mysql_error());

while($row = mysql_fetch_array($result2))
 { 
 ?>

and then within my form I would have the field that I want to update...

Code:
<TR><TD>Comments:</TD><TD><textarea cols='70' rows='10' name='<?=$_GET[form_field]?>'><?=$row[form_field]?></textarea></TD></TR>

However, the $row[form_field] doesn't display the content of that particular table field which is the value of test_field.

I am possibly doing this completely wrong but has anyone got any ideas on how I would achieve this?
 
How about:

Code:
<textarea cols='70' rows='10' name='<?=$_GET[form_field]?>'><?=$row[[red]$_GET['form_field'][/red]]?></textarea>



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Hi
I have tried that and all it does is print out the column name test_field instead of the value of that variable!

Any other ideas?
 
make sure your formield variable in $_GET is the name ofthe column you wish to output. That is if your column name is comment1 then your $_GET['fieldname'] variable should be equal to that.


you might also want to add semi colons at then of the statements like so:
Code:
<textarea cols='70' rows='10' name='<?=$_GET[form_field][red];[/red]?>'><?=$row[$_GET['form_field']][red];[/red]?></textarea>





----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
I have resorted to do this the long way by checking for each element and then updating accordingly, but thanks for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top