Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> przekazywanie checkbxow
szymono
post
Post #1





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 9.02.2004

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


mam taki problem
na jednej stroie tworzy sie lista osob jest to robione petla i wyciagane z bazy danych sql
wyglada to tak
[php:1:9af2f9b989]<?php
$link_id=db_connect();
if(!$link_id) die(sql_error());
$query = "select * from student";
$result = mysql_query($query) or die ("invalid query: " . mysql_error());

echo " <form method="post" action="usunstudenta.php"";


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

?>[/php:1:9af2f9b989]

i teraz na dole strony znajduje sie link ktory ma przekazac do tej samej strony tylko te pola przy ktorych zaznaczono checkboxa
link wyglada tak
Kod
<a href="index.php?file=listastudentow.php&action=del&studid=<? $del[studid] ?>">Usun zaznaczonych</a></td>

przy czym del to funkcja ktora ma wyswietlic ta tabelke z osobami przy ktorych zaznaczono checkboxy.
i wszystko sie dzieje na jednej stronie tej listastudentow
ale to nie chce dzialac? czy zle skonstruowalem linka (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) czy cos innego ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
szymono
post
Post #2





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 9.02.2004

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


Kossa chyba jednak cos nie tak robie albo moze pole chcekbox musi byc w tabeli (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)

teraz wyglada to tak:
[php:1:a5fe3192be]<?php
function pokaz_rekordy(){
global $php_self;
global $default_dbname;
?> <!--$szerokosc, $ramka, $odleglosc1=1, $odleglosc2=1-->

<!--DWLayoutTable-->

<tr>
<td height="21" colspan="7" valign="top" id="log">Lista studentow</td>
</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>
<br>
<?
html_header();
$link_id=db_connect();
if(!$link_id) die(sql_error());
$query = "select * from student";
$result = mysql_query($query) or die ("invalid query: " . mysql_error());
echo " <form method="post" action="index.php?file=listastudentow.php&action=delete">";
echo " <input type="submit" value = "usun zaznaczonych">";

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></form>";
}
if (action=="delete")
{
for ($i=0; $i<count($del); $i++)
{
$usun_id = $del[$i];
$query = "delete from student where studid = $usun_id";
$result = mysql_query ($query);

}
}

?>

<table>
<tr>
<td height="26" colspan="2" valign="top"> <input type="submit" name="Submit" value="Wystaw oceny zaznaczonym">
</td>

<td colspan="2" valign="top"><input type="button" value="Nowy" onClick="java script:winopen('nowystudent.php')"></td>
<td width="134" valign="top"><input type="submit" value="usun zaznaczonych"></td>
<td colspan="3" valign="top"><input type="button" name="Submit4" value="Wystaw obecnosci zaznaczonym"></td>
</tr>

</table>

<?

footer();
}
?>[/php:1:a5fe3192be]

it o jest ta funkcja pierwsza ktora pokazuje rekordy z tabeli
wciskam submit (dodalem sobie jeszcze jeden na gorze ) i nic sie nie dzieje. Gdzie mam blad juz kombinuje troche czasu i nic. Natomiast ta druga funkcje wywalilem
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 17.10.2025 - 04:39