在PHP中动态生成更新和删除表单。 [英] Dynamically generate update and delete form in PHP.

查看:67
本文介绍了在PHP中动态生成更新和删除表单。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!感谢目前为止所有的帮助。当我的老板说我应该尽快更新时,他的意思是上周。所以当我上班时,我得到了很好的欢乐。开始我的一天的好方法....


回到我的问题:


我在Mysql中有一个文本:获取代码它在PHP中是:

[PHP]

$ id = intval(mysql_real_escape_string($ _GET [''id'']));

$ query =" SELECT * FROM jos_issues WHERE jos_issues.contentid =''$ id''ORDER BY text desc" ;;

$ result = mysql_query($ query);


while($ row = mysql_fetch_array($ result)){

echo" $ row [text]< BR>" ;;

}

[/ PHP]


我正在寻找的是一种方式来支付
a)按一下链接进行更新

b)动态打印出一张表格。


我所追求的是一种编辑和删除数据库中所有文本的方法。它们都与内容$ id相关联。所以我的表看起来像这样:id |文字| contentid


我尝试了这段代码,但我得到的是一张非常空白的页面,上面没有任何内容:


[PHP]<?包括(QUOT; C:/db.inc"); error_reporting(E_ALL);

ini_set(''display_errors'',''1'');

// $ id = intval(mysql_real_escape_string($ _GET ['' id'']));

$ id = 12; echo" id = $ id";


$ query =" SELECT * FROM jos_issues WHERE jos_issues.contentid =''$ id''" ;;

$ result = mysql_query($ query);

$ num = mysql_numrows($ result);

// mysql_close();


$ i = 0;

while($ i< $ num){

$ text = mysql_result($ result,$ i," text") ;

< form action =" updated.php" method =" post">

< input type =" hidden"命名= QUOT; ud_id"值= QUOT;< ;? echo $ id; ?>">

文字:< input type =" text"命名= QUOT; ud_text"值= QUOT;< ;? echo $ text; ?>">< br>

< input type ="提交" value =" Update">

< / form>


++ $ i;

}

?> [/ PHP]


如果你能帮我解决这个问题,请告诉我。今天我没有午餐。我必须在一点钟完成,或者我被搞砸了......



提前致谢。


Phopman

解决方案

id = intval(mysql_real_escape_string(


_GET [''id''])) ;


query =" SELECT * FROM jos_issues WHERE jos_issues.contentid =''


Hi there! Thanks for all the help so far. When my boss said I should be up to date as soon as possible, he meant last week. So I got a good rollicking when I came to work. Nice way to start my day....

Back to my problem:

I have a Text in Mysql: The code for fetching it in php is:
[PHP]
$id = intval( mysql_real_escape_string( $_GET[''id''] ));
$query = "SELECT * FROM jos_issues WHERE jos_issues.contentid= ''$id'' ORDER BY text desc";
$result = mysql_query($query);

while($row= mysql_fetch_array($result)) {
echo"$row[text]<BR>";
}
[/PHP]

What I am looking for is a way to
a) press a link for update
b) dynamically print out a form for doing that.

All I am after is a way to edit and delete all the texts that are in my database. They are all linked to a content $id. So my table looks like this: id | text | contentid

I tried this code, but all I get is a very blank page with nothing on:

[PHP]<? include("c:/db.inc"); error_reporting(E_ALL);
ini_set(''display_errors'', ''1'');
//$id = intval( mysql_real_escape_string( $_GET[''id''] ));
$id = 12; echo "id = $id";

$query = "SELECT * FROM jos_issues WHERE jos_issues.contentid= ''$id''";
$result = mysql_query($query);
$num = mysql_numrows($result);
//mysql_close();

$i = 0;
while($i<$num) {
$text = mysql_result($result,$i,"text");
<form action="updated.php" method="post">
<input type="hidden" name="ud_id" value="<? echo $id; ?>">
Text: <input type="text" name="ud_text" value="<? echo $text; ?>"><br>
<input type="Submit" value="Update">
</form>

++$i;
}
?>[/PHP]

Let me know if you can help me with this one. There''s no lunch for me today. I have to have finished at one o'' clock, or I am screwed...


Thanks in advance.


Phopman

解决方案

id = intval( mysql_real_escape_string(


_GET[''id''] ));


query = "SELECT * FROM jos_issues WHERE jos_issues.contentid= ''


这篇关于在PHP中动态生成更新和删除表单。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆