So I have problem with firefox not showing results of search form for query i enter, but code is working normally in Opera,Chrome,IE and Android default browser.
This is the search form :
<div id="menu_right">
<div id="searchBar">
<form id='search_form' method='POST' action='index.php?menu=search'>
<input id="topSearchText" class="inputText" type="text" name="movie" size="30" onfocus="this.value=''" value="Search" style="color: rgb(119, 119, 119);"/>
<input type="image" name="search_movies" value="Search" src="./images/search.png"/>
</form>
</div>
and this is the php part of the code:
<table width='100%' cellspacing='0' cellpadding='0' border='0'>
<tbody>
<tr>
<td class='normal_header' colspan='2'>Search Results</td>
<td class='normal_header' width='40' align='center' nowrap=''>Score</td>
</tr>
<?php
if(isset($_POST['search_movies']))
{
$movie=$tmdb->searchMovie($_POST['movie']);
foreach ($movie['results'] as $value) {
$filepath = $value['poster_path'];
$image_url = $tmdb->getImageUrl($filepath, TMDb::IMAGE_POSTER, 'w92');
echo "
<tr>
<td class='borderClass bgColor' width='50' valign='top'>
<div class='picSurround'>
<a href='http://www.themoviedb.org/movie/{$value['id']}'>
<img border='0' src='{$image_url}'>
</a>
</div>
</td>
<td class='borderClass bgColor' valign='top'>
<a href='http://www.themoviedb.org/movie/{$value['id']} '>
<strong>{$value['title']}</strong>
</a>
<a class='button_add' title='Quick add movie to my list' href='addmovie.php?id={$value['id']}'>add</a>
<div class='spaceit'>
<a href='http://www.themoviedb.org/movie/{$value['id']}'>Read more about: {$value['title']}</a>
</div>
</td>
<td class='borderClass bgColor' align='center'>{$value['vote_average']}</td>
</tr>";
}
}
?>
</tbody>
Is it something wrong with my query or maybe some tag because I cant seem to find the problem.
Have you checked the error_log that was possibly created?
Also.. and I might be wrong here.. but as far as I know php only interprets code between double quotes "", not between single quotes ''.
So for instance:
$test = 5;
echo "this string shows the value of $test"
echo 'this string just shows the string $test';
If this is a search form based on the results of the input field then it should be;
isset($_POST['movie'])
Look at this question :
HTML Input (type=image) not working on Firefox 4
Maybe your problem comes from the way firefox handles image's input tag.
Edit : More infos in the accepted answer to this question : Code working in Chrome but not in Firefox
This seem to be a common "problem" with image-type inputs.
Related
I have my PHP code like below and its work fine
<tr onclick="window.location='../info/<?php echo $ouid;?>';" class="tbl_rated_orders">
Now I am loading more data on press load more button via ajax
so I am trying like this
$tableData.= '<tr class="tbl_rated_orders_buyer" onclick="window.location='.'"../info/'.$ouid.';">
<td>'.$date_rated.'</td>
<td><img src="../../global_assets/uploads/users/'.$image.'" width="35" class="rounded-pill" alt="">
<span class="ml-2">'.$rated_row["full_name"].'</span>
</td>
<td>'.$cancelled_by_txt.'</td>
<td><i class="icon-paperplane text-dark mr-1"></i>'.$str1.'</td>
</tr>';
But now tr html code looks like this
<tr class="tbl_rated_orders_buyer" onclick="window.location=" ..="" info="" zxp2ibhfnu;"="">
so its not correct code for window location, its need like this
<tr onclick="window.location='../info/RQ5KWBIY6M';" class="tbl_cancelled_orders">
I am new in PHP and trying from half hour to make it working but not getting idea how I can do it, Let me know if anyone here can help me for do the same.
Thanks!
You will need to escape some single quotes for the single quotes used in the javascript in the onclick attribute.
$ouid = "asd0f8a08f0";
$date_rated = "12/03/2021";
$image = "north_pole.jpg";
$rated_row["full_name"] = "Mighty Mouse";
$cancelled_by_txt = "grinch";
$str1 = "Paper Plane";
$tableData = "";
$tableData.= '<tr class="tbl_rated_orders_buyer" onclick="window.location='.'\'../info/'.$ouid.';\'">
<td>'.$date_rated.'</td>
<td><img src="../../global_assets/uploads/users/'.$image.'" width="35" class="rounded-pill" alt="">
<span class="ml-2">'.$rated_row["full_name"].'</span>
</td>
<td>'.$cancelled_by_txt.'</td>
<td><i class="icon-paperplane text-dark mr-1"></i>'.$str1.'</td>
</tr>';
Output:
<tr class="tbl_rated_orders_buyer" onclick="window.location='../info/asd0f8a08f0;'">
<td>12/03/2021</td>
<td><img src="../../global_assets/uploads/users/north_pole.jpg" width="35" class="rounded-pill" alt="">
<span class="ml-2">Mighty Mouse</span>
</td>
<td>grinch</td>
<td><i class="icon-paperplane text-dark mr-1"></i>Paper Plane</td>
Im creating a simple School grade system using only php and I'm stumped of trying to figure out how to get a hidden table to appear below the main table when click on a "durchschnitt number"
Below is the code for the main table
<?php
if (!isset ($_SESSION['Saved_contacts']))
$Kontakte = array (
array ("Hr.", "Fruehauf", "Dennis", "13.02.2002", "Brucknerweg 34", 5212, "Hausen", '<u>3.6</u>'),
array ("Fr.", "Kaufmann", "Katharina", "04.03.2002", "Neubertbogen 24", 1680, "Romont", "Durchschnitt"),
array ("Hr.", "Fiedler", "Marcel", "08.16.2002", "Via Stazione 98", 8143, "Stallikon", "Durchschinitt"),
array ("Hr.", "Oster", "Tim", "08.26.2002", "Via delle Vigne 98", 1773, "Vuaty", "Durchschinitt"),
array ("Fr.", "Eichelberger", "Tanja", "07.22.2002", "Semperweg 6", 4223, "Blauen", "Durchschinitt"));
else
$Kontakte = $_SESSION['Saved_contacts'];
?>
<div style="width: 80%; min-width: 550px">
<h2>Kontakt des Schülers ...</h2>
<table>
<tr> <th>Nr.</th> <th>Anrede</th> <th>Name</th> <th>Vorname</th> <th>Geburtsdatum</th> <th>Adresse</th> <th>PLZ</th> <th>Ort</th> <th>Durchschnitt</th> </tr>
<?php
for ($i=0; $i < count($Kontakte); $i++) {
echo "<tr> <td><em>".($i+1)."</em></td>" . "<td style='text-align: center'>".$Kontakte[$i][0]."</td>" .
"<td>".$Kontakte[$i][1]."</td>" . "<td>".$Kontakte[$i][2]."</td>" . "<td>".$Kontakte[$i][3]."</td>" .
"<td>".$Kontakte[$i][4]."</td>" . "<td>".$Kontakte[$i][5]."</td>" . "<td>".$Kontakte[$i][6]."</td>" . " <td>".$Kontakte[$i][7]."</td
" . " <td><</tr>";
}
?>
</table>
As you can see in the first aray on the last line i made a link so that i'm able to click it.
Below is the hidden table I want to hide and reappear
<div class="Note">
<div style="width: 80%; min-width: 550px">
<table class="grade_Fruehauf" style="">
<tr>
<th>Fruehauf</th>
</tr>
<tr>
<th>Deutsch</th>
<th>3.5</th>
</tr>
<tr>
<th>Math</th>
<th>3.5</th>
</tr>
<tr>
<th>Biologie</th>
<th>3.5</th>
</tr>
<tr>
<th>Französisch</th>
<th>4</th>
</tr>
<tr>
<th>Durchschnitt</th>
<th style="border-top:solid;">3.6<th>
</tr>
</table>
<div>
</div>
Appreciate your help :)
If you want to use PHP only then you can use session, on clicking link set a session variable in a different file and redirect back, check that session variable and show/hide w.r.t it. (though JavaScript is preferable)
It's better to use javascript.
You just need to add the onlick attribute on the "durchschnitt number" td like
<td onclick="show('tableid');"></td>
and specify an id to the div or the table (es.: <table class="grade_Fruehauf" style="" id="example">.
Then you need a javascript code like this:
<script>
function show(tableid){
var x=document.getElementById(tableid);
if (window.getComputedStyle(x).visibility === "hidden") {
x.style.visibility = "visible";
}else{
x.style.visibility = "hidden";
}
}
</script>
So Im developing Content Management System for my website! (Very Basic and I know some of these codes are going to be bad).
So Im using PDO and when I run this code.
public static function checkMain()
{
global $dbh;
if (isset($_POST['checkMain']))
{
$checkMain = $dbh->prepare("UPDATE `cms_system` SET `site_closed` = :site_closed LIMIT 1");
$checkMain->bindParam(':site_closed', $_POST['site_closed']);
if (!$checkMain->execute())
{
{
admin::succeed("no error");
return true;
}
admin::error("Uh Oh something is wrong" . $checkMain->errorInfo()[2]);
return;
}
}
}
Nothing happens I get no result nor does anything get updated in the database.
Here is my form tags
<form action="" method='POST' name='theAdminForm' id='theAdminForm'>
<div class='tableborder'>
<div class='tableheaderalt'>Turn your site on/off</div>
<?php admin::checkMain(); ?>
<table width='100%' cellspacing='0' cellpadding='5' align='center' border='0'>
<tr>
<td class='tablerow1' width='40%' valign='middle'><b>Close Site</b><div class='graytext'>If enabled, your site will be closed and show a maintenance page to regular users. Administrators can still login through Housekeeping.</div></td>
<td class='tablerow2' width='60%' valign='middle'><select name='checkMain' class='dropdown'>
<option value='0'>Site Open</option>
<option value='1'>Site Closed</option>
</select>
</td>
</tr>
<tr>
<tr><td align='center' class='tablesubheader' colspan='2' ><input type='submit' value='Apply' class='realbutton' accesskey='s'></td></tr>
</form>
Pretty much in a nutshell Im converting this really old Query
if(isset($_POST['site_closed'])){
$site_closed = addslashes($_POST['site_closed']);
mysql_query("UPDATE cms_system SET site_closed = '".$site_closed."' LIMIT 1") or die(mysql_error());
$msg = "Settings saved successfully.";
The Old Forum Tags.
<form action='index.php?p=maintenance&do=save' method='post' name='theAdminForm' id='theAdminForm'>
<div class='tableborder'>
<div class='tableheaderalt'>Turn your site on/off</div>
<table width='100%' cellspacing='0' cellpadding='5' align='center' border='0'>
<tr>
<td class='tablerow1' width='40%' valign='middle'><b>Close Site</b><div class='graytext'>If enabled, your site will be closed and show a maintenance page to regular users. Administrators can still login through Housekeeping.</div></td>
<td class='tablerow2' width='60%' valign='middle'><select name='site_closed' class='dropdown'>
<option value='1'>Site Closed</option>
<option value='0' <?php if(FetchCMSSetting('site_closed') == "0"){ echo "selected='selected'"; } ?>>Site Open</option>
</select>
</td>
</tr>
<tr>
<tr><td align='center' class='tablesubheader' colspan='2' ><input type='submit' value='Apply' class='realbutton' accesskey='s'></td></tr>
</form>
Into little but more updated version using PDO.
I need to pass value with href inside fetch array echo...
php code
$user = $get['username'];
$resource=mysqli_query($con,$sql);
echo "<font color=\"#000000\">
<h2 align=\"center\"></h2>
<table align=\"center\" border=\"1\" width=\"50%\">
<tr>
<td><b>GROUP NAME</b></td> <td><b>TASK TITLE 1</b></td> <td><b>TASK TITLE 2</b></td> <td><b>CREATED BY</b></td> <td><b>ASSIGNED TO</b></td> <td><b>DUE DATE</b></td> <td><b>PRIORITY</b></td> <td><b>CHANGE</b></td></tr> ";
while($result=mysqli_fetch_array($resource))
{
echo "<tr><td>".$result[0]."</td> <td>".$result[1]."</td> <td>".$result[2]."</td> <td>".$result[3]."</td> <td>".$result[4]."</td> <td>".$result[5]."</td> <td>".$result[6]."</td> <td> "<a href="changetask1.php?username='.$user.'">"</td></tr>";
} echo "</table></font>";
I need to pass username to next page with href value.
You are all messed up with quotes...
First... Learn to indent your code to make it readable.
Then, avoid echoing simple HTML if not necessary:
See your code after my «formatting»:
Try it, i've done a couple corrections...
<?php
$user=$get['username'];
$resource=mysqli_query($con,$sql);
?>
<!-- This is only HTML -->
<font color="#000000">
<h2 align="center"></h2>
<table align="center" border="1" width="50%">
<tr>
<td><b>GROUP NAME</b></td>
<td><b>TASK TITLE 1</b></td>
<td><b>TASK TITLE 2</b></td>
<td><b>CREATED BY</b></td>
<td><b>ASSIGNED TO</b></td>
<td><b>DUE DATE</b></td>
<td><b>PRIORITY</b></td>
<td><b>CHANGE</b></td>
</tr>
<?php
// This is a PHP block until the next ?>
while($result=mysqli_fetch_array($resource)){
echo "<tr>
<td>".$result[0]."</td>
<td>".$result[1]."</td>
<td>".$result[2]."</td>
<td>".$result[3]."</td>
<td>".$result[4]."</td>
<td>".$result[5]."</td>
<td>".$result[6]."</td>
<td><a href='changetask1.php?username=".$user."'></td>
</tr>";
}
?>
</table>
</font>
To avoid these problems of double and single quote you can write your code like following.
<td><a href="cheangetask1.php?username=<?php echo $user;?>"></td>
Now on the changetask1.php you can get username like this.
<?php echo $_REQUEST['username'];?>
I am dynamically loading question content into a div using jquery . This is my first attempt and it does load when I click the "Get Question"-button. However, the "Get Question"-button disappears when the question loads. I want the button to stay and eventually use it as a next question button.
Here is the jquery code:
<script type="text/javascript" src="../jquery/jquery/jquery-1.7.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(
$("#GetQuest").click(function(){
$.post("CCRN/question.php", {num : parseInt($("input#q_num").val()) + 1}, function (data) {
$("div#question").html(data);
$("input#q_num").val() = parseInt($("input#q_num").val()) + 1;
});
});
});
</script>
<input type="button" id="GetQuest" value="Get Question" />
<input type="hidden" id="q_num" value=1 />
<p>Question: <div id="question"> </div></p>
<p>Answer: <div id="answer"> </div></p>
Here is the question creating code (though the question loads and display fine)
<table width="100%"><?php
$i = $q_num;
if ($row["image"] <> NULL) { ?>
<tr align="center">
<td colspan="2" align="center">
<img src="<?php $pic = $row["image"]; echo $base_path . $pic; ?>" />
</td>
</tr><br />
<tr>
<td colspan="3"> </td>
</tr>
<?php
} ?>
<tr id="Qu<?php echo $i; ?>" class="Qu<?php echo $i; ?>">
<td width="7%"><?php echo $i.") " ?></td>
<td width="93%" ><?php echo $row["question"]; ?></td>
</tr>
<?php
for ($j=1;$j<=6;$j++) {
$bracket= "answer_" . $j;
if ($row[$bracket] !== NULL) {?>
<tr>
<td align="center" class="row<?php echo $j % 2; ?>" width="7%">
<input type="radio" <?php echo ($_POST["Q".$i] == $j) ? 'checked="checked"' : '' ; ?> name="Q<?php echo $i; ?>" value="<?php echo $j; ?>" /><?php echo chr(64 + $j); ?>
</td>
<td class="row<?php echo $j % 2; ?>" width="93%">
<?php echo $row["answer_".$j]; ?>
</td>
</tr> <?php
}
} ?>
</table><hr size="2" width="95%">
I do not understand why the button disappears when I load the question content. I am SURE it is something embarassing simple, which is why I am coming to a safe haven to minimize the ridicule! :)
Live test site http://www.GrowingSpeakers.com/index2.php to see the disappearing button.
You are using div with id "question" before.
<div class="TabbedPanelsContent" id="question">
and
<p>Question: <div id="question"> </div></p>
It does not matter even though the id's come from different files as long as they are displayed in the same DOM tree - they will be treated as one and the same.
You have 2 div's with the ID question and the javascript is going to replace the content of the first one found when you run:
$("div#question").html(data);
if you change the id for the first one it should work fine.