Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> usuniecie rekordu z bazy za pomoca checkboxa
seva
post
Post #1





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 6.03.2004

Ostrzeżenie: (0%)
-----


mam nastepujacy skrypt:


[php:1:4739cfd77a]<?php

require_once("config.php");
$ile = $config_ile;
mysql_connect("localhost", "test");
$result=mysql_db_query("test","SELECT mail, data, id FROM mailing LIMIT ".($page*$ile).",$ile");
while ($row=mysql_fetch_array($result)) {
for($a = 1; $a <= $b; $a++){
}
echo ("<table border='1' cellspacing='0' width='100%' class='tresc' bgcolor='#EFEFEF' bordercolor='#FFFFFF'cellpadding='0' style='border-collapse: collapse'>");
echo ("<tr>");
echo ("<td width='10%' align='center'>$a</td>");
echo ("<td width='50%'><left>&nbsp;&nbsp;<a href='mailto:".$row["mail"]."'</a>".$row["mail"]."</left></td>");
echo ("<td width='30%'><center>".$row["data"]."</center></td>");
echo ("<td width='10%'><center><input type='checkbox' name='usuniecie[]' value='$id'></center></td>");
echo ("</tr>");
echo ("</table>");
$b+=1;
list($wszystkich)=mysql_fetch_row(mysql_db_query("test","SELECT count(*) FROM mailing"));
$podstron=ceil($wszystkich/$ile-1);

}

if ($page>0){
echo "<a href=index.php?page=".($page-1).">Poprzednia</a>";} else
echo "Poprzednia";

echo ("&nbsp;&nbsp;&nbsp;&nbsp;");

for ($i=0; $i<=$podstron; $i++) {
if ($i==$page) echo "$i";}

echo ("&nbsp;&nbsp;&nbsp;&nbsp;");

if ($page<$podstron){
echo "<a href=index.php?page=".($page+1).">Następna</a>";} else
echo "Następna";


?>[/php:1:4739cfd77a]
<p align="right">

<input type="submit" name="usuwanie" value="Usuń zaznaczone" class="tresc"></p>


prosilbym o podanie konkretnego przykladu jaki skrypt musze uzyc aby, po zaznaczeniu jakiegos checkboxa (ktory odpowiada za konkretny adres e-mail) i nacisnieciu przycisku USUN - usunal sie z bazy danych rekord wlasnie z tym mailem... (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
kossa
post
Post #2





Grupa: Zarejestrowani
Postów: 1 165
Pomógł: 9
Dołączył: 9.04.2002
Skąd: Toruń

Ostrzeżenie: (0%)
-----


tu masz kod dzialajacy, dostosuj go do swoich potrzeb:


[php:1:3dda78032f]<?php
<table>
<tr><td height="21" colspan="7" valign="top" id="log">Lista studentow</td></tr>
<tr><td height="21" colspan="7" valign="top" id="log"><form method="post" action="index.php?file=istastudentow.php&action=delete"></td></tr>
<tr><td height="21" colspan="7" valign="top" id="log"><input type="submit" value = "usun zaznaczonych"></td></tr>
</tr>
<tr>
<td width="2%" height="26" id="kolor2">zaznacz</td>
<td width="10%" height="26" id="kolor2">imie</td>
<td width="10%" height="26" id="kolor2">nazwisko</td>
<td width="8%" height="26" id="kolor2">nr indeksu</td>
<td width="5%" height="26" id="kolor2">rok studiow</td>
<td width="5%" height="26" id="kolor2">semestr</td>
<td width="5%" height="26" id="kolor2">edytuj</td>
</tr>
<?php
global $action;

function PokazStudentow()
{
global $action;
$table = "student";
$query = "select * from $table";
$result = mysql_query($query) or die ("invalid query: " . mysql_error());

while ($query_data = mysql_fetch_array($result))
{
$studid = $query_data["studid"];
$imie=$query_data['stud_imie'];
$nazwisko=$query_data['stud_nazwisko'];
$indeks=$query_data['nr_indeksu'];
$rok=$query_data['rok_studiow'];
$semestr=$query_data['semestr'];
echo "<tr><td width="2%"><input type="checkbox" value="$studid" name="del[]"></td>";
echo "<td width="12%">".$imie."</td>";
echo "<td width="10 %">".$nazwisko."</td>";
echo "<td width="10 %">".$indeks."</td>";
echo "<td width="10 %">".$rok."</td>";
echo "<td width="10 %">".$semestr."</td>";
echo "<td width="5%">
<a href="index.php?file=listastudentow.php&action=edytuj&studid=$studid">wyswietl</a></td></tr>";
}

echo "</form></TABLE>";

};

if ($action=="delete")
{
for ($i=0; $i<count($del); $i++)
{
$usun_id = $del[$i];
$query = "delete from student where id = $usun_id";
$result = mysql_query ($query);
}
}

PokazStudentow();


?>[/php:1:3dda78032f]

Kossa
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 26.12.2025 - 17:05