HTML/PHP - Send data with link without using JavaScript -
i'm new web programming , have problem website i'm trying : want send data .php page when user clicks link (there several links, each link title of newspaper article , when user clicks 1 of them, sends id of article because next page has load content of article). must not use javascript.
here previous code :
<h2> articles </h2> <?php $articlessql = "select id, title article a, approvearticle va a.id = va.article , va.state='published';"; $articlesquery = pg_query($connect, $articlessql); while($articlesresult = pg_fetch_array($articlesquery)) { echo "<form id=\"linkarticle\" action=\"article.php\">"; echo "<input type=\"hidden\" name=\"article\" value=\"$articlesresult[id]\"> </form>"; echo "<a href='#' onclick='document.getelementbyid(\"linkarticle\").submit()'> $articlesresult[title] </a> <br/>"; } ?>
is there way avoid using javascript? if so, how do?
thank in matter , have nice day.
there no way submit form without using submit button html only.
you can make button link. require css. have @ this thread inspiration.
a better alternative solves problem ditch form completely.
simply include article id want transfer php script url parameter:
echo "<a href=\"article.php?article=$articlesresult[id]\"> $articlesresult[title] </a> <br/>";
after user clicked link, able read article id using $_get['article']
.
Comments
Post a Comment