Hello! I have a dynamic page with page navigation. Displays 3 elements on the page with a countdown by id. I need to find out the id of these elements of the current page, i.e., the elements with id 1, 2, 3 were output from the database, their id is in this link id use (in list). Please, if you write the code, explain what is being done, otherwise I recently do php. The code is still explained. Thank.

Here is the code:

Тут выводится три элемента (стихотворения) на странице: <?php printf("<h2 align='center' style='font-size:15px'>%s</h2><div style='text-align:center'>%s <p style='color:#A6A6A6; font-size:14px'>автор: <b>%s</b><br> добавлено: <b>%s</b><br> <b><a style='color:#A6A6A6; font-size:14px' href='proverka_coda1.php?id=%s'>редактировать >></a></b></p></div><p align='center'>Рейтинг:<img src='images/%s.gif'></p> <form style='text-align:center' action='pereschet7.php' method='post' name='vv'> <p class = 'pvote' >1<input name='score' type='radio' value='1'>2<input name='score' type='radio' value='2'>3<input name='score' type='radio' value='3'>4<input name='score' type='radio' value='4'>5<input name='score' type='radio' value='5' checked> <input class='sub_vote' name='submit' type='submit' value='Оценить'> <input name='id' type='hidden' value= '%s'> <input name='cat' type='hidden' value='$cat'> </p> </form><br>", $myrow['nazv'], $myrow['text'], $myrow['title'], $myrow['date'], $myrow['id'], $r, $myrow['id']); } while($myrow = mysql_fetch_array($result)); echo "<p align='left' style='font-size:15px; margin-bottom:20px'><b>КОММЕНТАРИИ:</b></p>"; $result4 = mysql_query ("SELECT * FROM commentavtorskie WHERE page='$page' AND cat='$cat' ORDER BY id",$db); if (mysql_num_rows($result4) > 0) { $myrow4 = mysql_fetch_array($result4); do { printf ("<div class='commentarii'><span style='float:left; margin-bottom:15px'>Добавил(а): <b>%s</b></span> <span style='float:right; margin-bottom:15px'>Дата: <b>%s</b></span> <p class='comment'>%s</p></div>",$myrow4["author"], $myrow4["date"], $myrow4["text"]); } while ($myrow4 = mysql_fetch_array($result4)); } $result5 = mysql_query ("SELECT img FROM comments_setting",$db); $myrow5 = mysql_fetch_array($result5); ?> 

Here in the list I want to display the names of the verses with id, so that the user chooses. I need the id of these three poems that brought up above. id I want to use further in the handler so that a message like: “a comment has been added to your poem” came to the mail. How to get id?

 <p align='left' style='font-size:15px'><b>ДОБАВИТЬ КОММЕНТАРИЙ:</b></p> <form action="commentavtorskie.php" method="post" name="form_com"> <p><label>Ваше имя: </label><input name="author" type="text" size="25" maxlength="30"></p> <p><label>Текст комментария: <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<textarea name="text" cols="31" rows="5"></textarea></label></p><p>Введите сумму чисел с картинки:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="<? echo $myrow5["img"]; ?>">&nbsp; <input name="pr" type="text" size="7" maxlength="5"></p> <input name="page" type="hidden" value="<? echo $page; ?>"> <input name="cat" type="hidden" value="<? echo $cat; ?>"> <p><input name="sub_com" type="submit" value="Комментировать"></p> </form> </div> </div> <? include ("blocks/footer.php"); ?> </body> </html> 

    1 answer 1

    1) First, here is wrong:

      do { printf ("<div id='commentarii'><span style='float:left; margin- 

    ID in the page should be only 1! But the classes as you want.

    2) brother content by item id:


    document.getElementById ('myId'). innerHTML;

    id like this:

     var getId = function(){ alert(this.id); } var elements = document.getElementsByTagName('div'); // All divs for(var i = 0; i<elements.length; i++){ elements[i].onclick = getId; } 

    Example link

    • I do not know, it does not work, explain, please, the function, I do not understand this very well. - Regina