Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [CSS + php + html] jak przekazac a href do php
q250
post 1.09.2007, 00:57:40
Post #1





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 29.07.2007

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


Jest takie cos jak star rating poprzez html + css bardzo proste:

Problem mam tylko taki, ze majac taki kod html:

  1. <ul class="star-rating">
  2. <li class="current-rating" style="width:60%;">Currently 3/5 Stars.</li>
  3. <li><a href="#1" title="1 star out of 5" class="one-star">1</a></li>
  4. <li><a href="#2" title="2 stars out of 5" class="two-stars">2</a></li>
  5. <li><a href="#3" title="3 stars out of 5" class="three-stars">3</a></li>
  6. <li><a href="#4" title="4 stars out of 5" class="four-stars">4</a></li>
  7. <li><a href="#5" title="5 stars out of 5" class="five-stars">5</a></li>
  8. </ul>


nieumiem wyniku z href wyslac tak jak ponizej z "selecta" za pomoca formularza, jak to zrobic?

  1. <form name='postrating' method='post' action='".$rating_link."'>
  2. <select name='rating' class='textbox'>
  3. <option value='0'>1</option>;
  4. <option value='0'>2</option>;
  5. <option value='0'>3</option>;
  6.  
  7. <input type='submit' name='post_rating' value='".$locale['r103']."' class='button'>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
-Wieviór-
post 1.09.2007, 07:48:14
Post #2





Goście







Wytłumacz dokładniej co chcesz zrobić, bo ja nie do końca to rozumiem, ale widzę już na pewno jeden błąd - czemu wszystkie opcje w select mają value równy "0"? Nie powinny mieć 1, 2, 3, 4, 5?

Poza tym - używaj grubych cudzysłowów do argumentów html'a ,a cienkich do przechodzenia w PHP ;]
Go to the top of the page
+Quote Post
TomASS
post 1.09.2007, 08:29:59
Post #3





Grupa: Zarejestrowani
Postów: 1 660
Pomógł: 13
Dołączył: 9.06.2004
Skąd: Wrocław i okolice

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


No postem za bardzo w linku nie wyślesz danych.
Jeśli byś miał:
  1. <form name="postrating" method="GET" action="fromform.php">
  2. <select name="rating" class="textbox">
  3. <option value="1">1</option>;
  4. <option value="2">2</option>;
  5. <option value="3">3</option>;
  6. <option value="4">4</option>;
  7. <option value="5">5</option>;
  8.  
  9. <input type="submit" name="post_rating" value="costam" class="button">

to możesz "równoważnie" dać:
  1. <ul class="star-rating">
  2. <li class="current-rating" style="width:60%;">Currently 3/5 Stars.</li>
  3. <li><a href="fromform.php?rating=1&post_rating=costam" title="1 star out of 5" class="one-star">1</a></li>
  4. <li><a href="fromform.php?rating=2&post_rating=costam" title="2 stars out of 5" class="two-stars">2</a></li>
  5. <li><a href="fromform.php?rating=3&post_rating=costam" title="3 stars out of 5" class="three-stars">3</a></li>
  6. <li><a href="fromform.php?rating=4&post_rating=costam" title="4 stars out of 5" class="four-stars">4</a></li>
  7. <li><a href="fromform.php?rating=5&post_rating=costam" title="5 stars out of 5" class="five-stars">5</a></li>
  8. </ul>

i później w pliku fromform.php pobrać to $_GET lub $_REQUEST


--------------------
Go to the top of the page
+Quote Post
q250
post 1.09.2007, 10:43:13
Post #4





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 29.07.2007

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


A no wlasnie, problem w tym TomASS ze najlepiej byloby to zrobic w tym samym pliku, trzeba angazowac w to kolejny plik? Bo wyswietlanie gwiazdek (a href + li) jest w tym samym pliku co formularz, da sie z przekazac te dane z href w tym samym pliku do formularza?

Bo chodzi ze po kliknieciu na gwiazdke wysle dane w ktora kliknieto ;p a pomoca tego href a wczesniej robil to ten formularz 1,2,3,4,5 a ma go zastapic klikanie w gwiazdki

Ten post edytował q250 1.09.2007, 10:49:15
Go to the top of the page
+Quote Post
TomASS
post 1.09.2007, 10:56:54
Post #5





Grupa: Zarejestrowani
Postów: 1 660
Pomógł: 13
Dołączył: 9.06.2004
Skąd: Wrocław i okolice

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


Noto nazywasz sobie plik po prostu fromform.php tongue.gif Plik możesz nazwać jak chcesz.

  1. <?
  2. if(!$_GET['rating']){
  3. ?><ul class="star-rating">
  4. <li class="current-rating" style="width:60%;">Currently 3/5 Stars.</li>
  5. <li><a href="fromform.php?rating=1&post_rating=costam" title="1 star out of 5" class="one-star">1</a></li>
  6. <li><a href="fromform.php?rating=2&post_rating=costam" title="2 stars out of 5" class="two-stars">2</a></li>
  7. <li><a href="fromform.php?rating=3&post_rating=costam" title="3 stars out of 5" class="three-stars">3</a></li>
  8. <li><a href="fromform.php?rating=4&post_rating=costam" title="4 stars out of 5" class="four-stars">4</a></li>
  9. <li><a href="fromform.php?rating=5&post_rating=costam" title="5 stars out of 5" class="five-stars">5</a></li>
  10. </ul><?
  11. }
  12. else{
  13. print_r($_GET);
  14. }?>


przykład

Ten post edytował TomASS 1.09.2007, 11:32:59


--------------------
Go to the top of the page
+Quote Post
q250
post 1.09.2007, 13:13:25
Post #6





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 29.07.2007

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


Ok wkoncu sie udalo smile.gif dzieki serdeczne pomoglo mi to bardzo!!
Go to the top of the page
+Quote Post

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 Wersja Lo-Fi Aktualny czas: 20.07.2025 - 09:34