Inclure du code javascript dans du php
brazza
-
Alain42 -
Alain42 -
Bonjour,
Je souhaite avoir de vos lumières sur un petit pb.
Je m'explique : J'ai une page php ci-joint le code
------
<table width="95%" border="0" cellspacing="0" cellpadding="0" align="center">
</tr>
<? if (!$action) {
?>
<tr valign="top">
<? if ($licat_id != "0") {
?>
<td width="100%" colspan="3" align="center"><span class="blog"><b><?=$linkcat_name?></b></span></td>
</tr>
<? }
?>
<?=$links?>
</table>
<table width="95%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr valign="top">
<td width="100%" colspan="3" height="10"></td>
</tr>
<?=$linkhtmlrec?>
<td width="100%" colspan="3" height="10"></td>
</tr>
<tr valign="top">
<td width="100%" colspan="3" align="center"><span class="blog"><a href="<?=$root_url?>/links.php?action=add"><?=LANG_SUBMITLINKS?></a> | <a href="<?=$root_url?>/links.php"><?=LANG_LINKSINDEX?></a></span></td>
<? }
if ($action == "search") { ?>
<tr valign="top">
<td width="100%" colspan="3" height="10"></td>
</tr>
<?
dbconnect();
$link_sql = "SELECT * FROM $t_links WHERE link_validated = 'yes' AND
(link_name LIKE '%$linksearch%' OR link_desc LIKE '%$linksearch%')
ORDER BY link_totalrate, link_numvotes, link_hits ASC, link_name DESC";
$link_result = build_linkhtmlrec($link_sql);
$cat_sql = "SELECT lcat_id, lcat_name, lcat_ranking FROM $t_linkcat WHERE
(lcat_name LIKE '%$linksearch%' OR lcat_header LIKE '%$linksearch%')
ORDER BY lcat_ranking DESC, lcat_name";
$cat_result = cats_sql($cat_sql);
if ((!$linksearch) || (!$link_result)) {
?>
<tr valign="top">
<td width="100%" colspan="3" align="left"><span class="titre_liens"><?=LANG_NOSEARCHRESULTS?> <b>: <?=$linksearch?></b><br>
<?=LANG_NOSEARCHRESULTS_MESSAGE?></span></td>
</tr>
<?
} else {
echo "$cat_result";
?>
<?
echo "$link_result";
}
?>
<tr valign="top">
<td width="100%" colspan="3" height="10"></td>
</tr>
<tr valign="top">
<form action=<?=$root_url?>/links.php method=get>
<td width="100%" colspan="3" align="center"><b><?=LANG_SEARCHLINKS?>:</b>
<input type="test" size="25" name="linksearch" class="boutons">
<input type="hidden" name="action" value="search">
<input type="submit" value="brazza" style="BACKGROUND-COLOR: #FFFFFF; BORDER-BOTTOM: #0B0B0B 1px solid; BORDER-LEFT: #0B0B0B 1px solid; BORDER-RIGHT: #0B0B0B 1px solid;
BORDER-TOP: #0B0B0B 1px solid; COLOR: #004F78; FONT-FAMILY: Arial,Verdana; FONT-SIZE: 9pt"><br>
<input type="radio" name="brazza_radio" value="guide" checked><span class="blog">Dans tout le guide</span>
<input type="radio" name="brazza_radio" value="categorie"><span class="blog">Dans la catégorie</span>
</td>
</form>
</tr>
<tr valign="top">
<td width="100%" colspan="3" height="10"></td>
</tr>
<tr valign="top">
<td width="100%" colspan="3" align="center"><span class="blog"><a href="<?=$root_url?>/links.php?action=add"><?=LANG_SUBMITLINKS?></a> | <a href="<?=$root_url?>/links.php"><?=LANG_LINKSINDEX?></a></span></td>
</tr>
<? } ?>
</table>
-----
Dans ce code j'ai un formulaire de recherche. Et je veux distinguer la recherche selon que je clique sur l'option " radio bouton". En effet dans la même formulaire quand je clique sur le bouton "submit avec le choix du bouton1, la recherche s'effectue sur l'ensemble de mon guide et sinon sur une partie de mon guide.
Comment peux faire?
Cordialment,
Je souhaite avoir de vos lumières sur un petit pb.
Je m'explique : J'ai une page php ci-joint le code
------
<table width="95%" border="0" cellspacing="0" cellpadding="0" align="center">
</tr>
<? if (!$action) {
?>
<tr valign="top">
<? if ($licat_id != "0") {
?>
<td width="100%" colspan="3" align="center"><span class="blog"><b><?=$linkcat_name?></b></span></td>
</tr>
<? }
?>
<?=$links?>
</table>
<table width="95%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr valign="top">
<td width="100%" colspan="3" height="10"></td>
</tr>
<?=$linkhtmlrec?>
<td width="100%" colspan="3" height="10"></td>
</tr>
<tr valign="top">
<td width="100%" colspan="3" align="center"><span class="blog"><a href="<?=$root_url?>/links.php?action=add"><?=LANG_SUBMITLINKS?></a> | <a href="<?=$root_url?>/links.php"><?=LANG_LINKSINDEX?></a></span></td>
<? }
if ($action == "search") { ?>
<tr valign="top">
<td width="100%" colspan="3" height="10"></td>
</tr>
<?
dbconnect();
$link_sql = "SELECT * FROM $t_links WHERE link_validated = 'yes' AND
(link_name LIKE '%$linksearch%' OR link_desc LIKE '%$linksearch%')
ORDER BY link_totalrate, link_numvotes, link_hits ASC, link_name DESC";
$link_result = build_linkhtmlrec($link_sql);
$cat_sql = "SELECT lcat_id, lcat_name, lcat_ranking FROM $t_linkcat WHERE
(lcat_name LIKE '%$linksearch%' OR lcat_header LIKE '%$linksearch%')
ORDER BY lcat_ranking DESC, lcat_name";
$cat_result = cats_sql($cat_sql);
if ((!$linksearch) || (!$link_result)) {
?>
<tr valign="top">
<td width="100%" colspan="3" align="left"><span class="titre_liens"><?=LANG_NOSEARCHRESULTS?> <b>: <?=$linksearch?></b><br>
<?=LANG_NOSEARCHRESULTS_MESSAGE?></span></td>
</tr>
<?
} else {
echo "$cat_result";
?>
<?
echo "$link_result";
}
?>
<tr valign="top">
<td width="100%" colspan="3" height="10"></td>
</tr>
<tr valign="top">
<form action=<?=$root_url?>/links.php method=get>
<td width="100%" colspan="3" align="center"><b><?=LANG_SEARCHLINKS?>:</b>
<input type="test" size="25" name="linksearch" class="boutons">
<input type="hidden" name="action" value="search">
<input type="submit" value="brazza" style="BACKGROUND-COLOR: #FFFFFF; BORDER-BOTTOM: #0B0B0B 1px solid; BORDER-LEFT: #0B0B0B 1px solid; BORDER-RIGHT: #0B0B0B 1px solid;
BORDER-TOP: #0B0B0B 1px solid; COLOR: #004F78; FONT-FAMILY: Arial,Verdana; FONT-SIZE: 9pt"><br>
<input type="radio" name="brazza_radio" value="guide" checked><span class="blog">Dans tout le guide</span>
<input type="radio" name="brazza_radio" value="categorie"><span class="blog">Dans la catégorie</span>
</td>
</form>
</tr>
<tr valign="top">
<td width="100%" colspan="3" height="10"></td>
</tr>
<tr valign="top">
<td width="100%" colspan="3" align="center"><span class="blog"><a href="<?=$root_url?>/links.php?action=add"><?=LANG_SUBMITLINKS?></a> | <a href="<?=$root_url?>/links.php"><?=LANG_LINKSINDEX?></a></span></td>
</tr>
<? } ?>
</table>
-----
Dans ce code j'ai un formulaire de recherche. Et je veux distinguer la recherche selon que je clique sur l'option " radio bouton". En effet dans la même formulaire quand je clique sur le bouton "submit avec le choix du bouton1, la recherche s'effectue sur l'ensemble de mon guide et sinon sur une partie de mon guide.
Comment peux faire?
Cordialment,
A voir également:
- Inclure du code javascript dans du php
- Code ascii - Guide
- Code puk bloqué - Guide
- Code activation windows 10 - Guide
- Comment déverrouiller un téléphone quand on a oublié le code - Guide
- Code blocks - Télécharger - Langages
1 réponse
Bonjour,
tu n'as pas besoin de javascript.
Il suffit dans ton script (<?=$root_url?>/links.php) qui va traiter le recherche de détecter quel est le bouton radio coché
$_GET['brazza_radio']
qui aura la valeur guide ou categorie
et en fonction de ça tu fais une recherche différente
qqs remarques en passant:
- utilises les tags php <?php ?> au lieu de <? ?>
- mets des " dans <form action="...." method="...."
@lain
tu n'as pas besoin de javascript.
Il suffit dans ton script (<?=$root_url?>/links.php) qui va traiter le recherche de détecter quel est le bouton radio coché
$_GET['brazza_radio']
qui aura la valeur guide ou categorie
et en fonction de ça tu fais une recherche différente
qqs remarques en passant:
- utilises les tags php <?php ?> au lieu de <? ?>
- mets des " dans <form action="...." method="...."
@lain