dpps0715 2014-01-29 11:59
浏览 47

打开手风琴时,请通过该文章的ID获取网址

I want to display the article ID in my URL when i press the a href in code beneath

Update, i included the php section and the while loop with the article ID

require_once("inc/connection.php");
mysql_select_db("nieuws");
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$id = $_GET['id'];
$datum = $_POST["datum"];
$titel = $_POST["titel"];
$artikel = $_POST["artikel"];
$checkbox = $_POST["checkbox"];
$titel = mysql_real_escape_string(nl2br(htmlentities($_POST["titel"])));
$artikel = mysql_real_escape_string($_POST["artikel"]);
$id = mysql_real_escape_string($_POST['id']);
date_default_timezone_set('GMT');
$datum = date('Y-m-d', strtotime(str_replace('-', '/', $datum)));
    if(isset($_POST['add'])){
        if(!empty($_POST['titel']) && !empty($_POST['artikel']) && !empty($_POST['datum'])){
        $query="INSERT INTO nieuws (id,datum,titel,artikel) VALUES ('$id','$datum','$titel','$artikel')";
        $datum = date('Y-m-d', strtotime(str_replace('-', '/', $datum)));
        str_replace('<br />', "
", $textarea);
        $result=mysql_query($query);
        $juist1 = true;
        }else{
        $fout1 = true;
        }
    }if(isset($_POST['delete'])){
        foreach($_POST['checkbox'] as $del_id){
        $sql="DELETE FROM nieuws WHERE id='$del_id'";
        $result = mysql_query($sql);
        $juist2 = true;
        }
        }
}

This is the accordion script that opens on click

$('.acc_container').hide(); //Hide/close all containers
$('.acc_trigger').click(function(){
if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
    $('.acc_trigger').removeClass('active').next().slideUp();
    $(this).toggleClass('active').next().slideDown();
}
return false;
});
});

This is the FORM part

<form method="POST" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
<table style="width:950px; margin-bottom:5px;">
<tr>
<td>Datum:<br />
<input type="text" name="datum" size="20" style="width:100px;" value="<?php echo $datum;   ?>" id="datepicker" placeholder="Kies datum"/><br /></td>
<td>Titel:<br />
<input type="text" name="titel" size="200" style="width:500px;" maxlength="45" value="<? php echo $titel; ?>" placeholder="Max. 50 characters toegelaten"/><br /></td>         </tr>
</table>            
Artikel: <br />
<textarea id="textarea" name="artikel" style="width:500px; height:150px;" value="<?php  echo $artikel; ?>" ></textarea><br />

<input type="submit" name="add" value="Artikel toevoegen" />
</form>

This is the while loop where i ADD the row ID

$query="SELECT id,datum,titel,artikel FROM nieuws ORDER BY id DESC";
$result=mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo ("<div id=\"artikeltitel\" align=\"center\">
    <div id=\"containerdatum\">".$row['datum']."</div>
    <div id=\"containertitel\">".$row['titel']."</div>
    <div id=\"container3\" style=\"font-size:12px;\">".$row['id']."
    <input type=\"checkbox\" name=\"checkbox[]\" id=\"checkbox\"   value=\"".$row['id']."\"       />
    </div>
    </div>
    <div class=\"container\" align=\"center\">
    <h2 class=\"acc_trigger\"><a href=".$row['id']."> &#187; </a></h2>
    <div class=\"acc_container\">
    <div class=\"block\">".$row['artikel']."</div>
    <div class=\"fb-comments\" data-href=\"http://www.zpb-polonez.be/user.php\" data-num-    posts=\"10\" data-width=\"678\" style=\"margin-top:2px;\"></div>
    </div>
    </div>
    ");
}

I don't know what to add more to explain what i'm trying to achive

  • 写回答

1条回答 默认 最新

  • dongxie45083 2014-01-30 10:51
    关注

    We lack some information here to be able to help but let's try anyway.

    Let's assume that your article id is $row['id'] you could build your link this way:

    echo '<a href="#' . $row['id'] . '">Link</a>';
    
    评论

报告相同问题?

悬赏问题

  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思