Evening All, just trying to figure out why some of my variables are not echoing from my MYSQL database. At first they were going to be Session variables of which i found did not work, so then i changed to a mysql query on my invoice page
$OrderID = $_SESSION[OrderID];
$LName = mysql_result(mysql_query("SELECT LName FROM customers WHERE Username = '$Username'"), 0);
$Fname = mysql_result(mysql_query("SELECT FName FROM customers WHERE Username = '$Username'"), 0);
$Date = mysql_result(mysql_query("SELECT Date FROM orders WHERE OrderID = '$OrderID'"), 0);
My Queries above. Order ID and Date are working, yet Lname and Fname are not where everything is named correctly as they are in the database.
Full Code below of where i am trying to echo them.
<div id='containter' style='position:absolute;width:750px;height:800px; left:50% ; margin-left: -375px; border-style: solid;border-width: 1px;'>
<div id='heading' style='position:absolute;width:650px;height:100px; left:50% ; margin-left: -325px;top:20px; border-style: solid;border-width: 1px;'>
<div style='position:absolute;left:500px;text-align:center;font-size:36px;'> <p>INVOICE </p></div>
<div style='position:absolute;text-align:center;font-size:38px;width:250px;left:-20px;'> OzScopes</div>
<div style='position:absolute;text-align:center;font-size:16px;width:250px;left:-37px;top:45px;'> ozscopes.com.au</div>
<div id='headingbottom' style='position:absolute;width:100%;height:20px;top:80px;'>
<table>
<tr>
<td style='position:absolute;left:5%;'>Invoice Number </td>
<td style='position:absolute;left:25%;'> <?php echo $OrderID;?> </td>
<td style='position:absolute;left:77%;'><?php echo $Date ;?></td>
</tr>
</table>
</div>
</div>
<div id='invoicecontent' style='position:absolute;width:650px;height:600px; left:50% ; margin-left: -325px;top:140px; border-style: solid;border-width: 1px;'>
<div id='information'>
<div id='customerinfo' style='position:absolute;width:255px;height:75px;top:-210px;padding:10px; border-bottom: 2px solid;border-right:1px solid; display:inline'>
<table>
<tr>
<th>Customer Information</th>
</tr>
<tr>
<td> <?php echo $LName;?> lnametest</td>
</tr>
</table>
</div>
<div id='mailinginfo' style='position:absolute;width:355px;height:75px;left:275px;top:-210px;padding:10px;border-bottom: 2px solid; display:inline'>
Mailing Information
</div>
</div>
<div id='products' style='position:absolute;top:97px;width:650px;height:503px;'>
<?php
echo "<table border=\"0\" cellspacing=\"0\" padding=\"0\" width=\"650px\">";
echo "<tr style='font-weight: bold; font-size:16px;'>";
echo "<td colspan=\"2\" align=\"center\" style='border-bottom: 2px solid;font-family:'Ek Mukta';color:#464d48;'>Description</td>";
echo "<td align=\"left\" style='border-bottom: 2px solid;font-family:'Ek Mukta';color:#464d48;'>Quantity</td>";
echo "<td colspan=\"3\" align=\"center\" style='border-bottom: 2px solid ;font-family:'Ek Mukta';color:#464d48;'>Price (Per Unit)</td>";
echo "<td align=\"center\" style='border-bottom: 2px solid;font-family:'Ek Mukta';color:#464d48;'>Total</td>";
echo "</tr>";
echo "</table>";
?>
</div>
<div id='payment'>
</div>
</div>
</div>
Where are you getting $Username? should you get it from the session first?
Like so:
$Username = $_SESSION[Username];
otherwise this string is empty and the select statement will come back as empty, because the where clause was based on username = $Username (which in this case is empty).
Get username of the session variable first, then use it in where clause. Apart from that, as others have said, please avoid using mysql queries, use mysqli instead.
Hope it helps.
Related
I feel stuck with a bit unusual situation for me up until now ... I constructed a HTML table that shows quantities from different locations by reading and rows from SQL DB into a $locations variable that is essentially an array - here's the code:
while ($location = mssql_fetch_array($locations)){
echo"
<tr>
<td style='text-align:center; padding-left: 2px; padding-right: 2px'>$location[1]</td>
<td style='text-align:center; padding-left: 2px; padding-right: 2px'>$location[2]</td>
<td width='50' style='text-align:center; padding-left: 2px; padding-right: 2px'><input type='number' style='border:none;text-align:center;' class='input' name='qty_to_add[]' type='text' value='' min='1' max='999'></td>
</tr>";
};
But the real problem is how do I read only cells in the third column to the right, that have values imputed and pass only those to an update query that will further update only those rows that contain locations POL_12 (15 pcs + 5 more) and POL_54 (30 pcs + 7 more)?
I need to do this in a procedural way, since I am not yet familiar with OOP and PDO (but I am striving to learn it soon) :/
Please advise, all suggestions are welcome! Thank Y'all!
In this scenario, following Barmar's advice (because it seemed most familiar to me in this moment) - using hidden fields in a form combined with for loop worked like a charm!
<form method="post" enctype="multipart/form-data">
<table style="width:100%" border="2">
<tr>
<th style="text-align:center; padding-left: 2px; padding-right: 2px">Location</th>
<th style="text-align:center; padding-left: 2px; padding-right: 2px">Qty</th>
<th style="text-align:center; padding-left: 2px; padding-right: 2px">Qty to add</th>
</tr>
<?php
$locations = mssql_query("my query for reading item name, location and quantity per location ");
while ($location = mssql_fetch_array($locations))
{
echo"
<tr>
<input style='border:none;text-align:center;' class='input' name='location_id[]' type='hidden' value='$location[0]'>
<input style='border:none;text-align:center;' class='input' name='item_id[]' type='hidden' value='$location[3]'>
<td style='text-align:center; padding-left: 2px; padding-right: 2px'>$location[1]</td>
<td width='2' style='text-align:center; padding-left: 2px; padding-right: 2px'><input type='number' style='border:none;text-align:center;' class='input' name='current_qty[]' type='text' value='";if (!isset($location[2])) {echo "0";} else {echo $location[2];}; echo "'></td>
<td width='50' style='text-align:center; padding-left: 2px; padding-right: 2px'><input type='number' style='border:none;text-align:center;' class='input' name='qty_to_add[]' type='text' value='0' min='0' max='999'></td>
</tr>";
};
?>
</table></br>
<input id="post" class="search" name="submit" type="submit" value="POST" style="position: relative"></br>
</form>
<?php
if (isset($_POST['submit']))
{
$location_id = $_POST['location_id'];
$ite_id = $_POST['item_id'];
$curr_qty = $_POST['current_qty'];
$added_qty = $_POST['qty_to_add'];
$rowCount = count($_POST['location_id']);
for ($i = 0; $i < $rowCount; $i++)
{
if ($added_qty > 0)
{
$query = mssql_query("update [my-table-name] set qty_per_location = cast('$curr_qty[$i]' as decimal (5,2)) + cast('$added_qty[$i]' as decimal (5,2)) where item_id = $item_id[$i] and item_location_id = $location_id[$i]");
echo "<br/><br/><span>Data inserted to DB successfully!</span>";
}
}
}
?>
I don't want to sound disrespectful to others, that suggested possible solutions - I chose this solution merely because it was understandable for my current novice level of knowledge! Instead a big shoutout to all that sacrificed a lil' bit their time to contribute. Thank y'all!
I have this below script that load the selected table row details in a div in the same page with ajax.
$('.positiontitle-link').click(
function(){
var durl = $(this).attr('ref');
$('#details').load(durl)
}
)
This is my Table where it have two column. First column used to list the jobs from MySQL database and the second used to view the selected row full details.
<table class="table1" width="100%" cellpadding="0" cellspacing="0" style="height: 100%; z-index:1; top:0; position: absolute;">
<tr>
<td width="30%" style=" min-width:40px;padding:0; background-color:rgba(255, 255, 255, 0.9); height: 100%; bottom: 0; top:0;" valign="top">
<div style="margin: 0; padding: 0; overflow-x:hidden; height: 100%; position: inherit; bottom: 0; top:0;">
<?php
require "module/call.php";
?>
</div>
</td>
<td width="60%" style="min-width:40px;padding:0; background-color:rgba(255, 255, 255, 0.9); height: 100%; bottom: 0; top:0;" valign="top"><div id="details" style="overflow:auto; width:100%; border-left-width: thin; border-right-width: 0; border-top-width: thin; border-bottom-width: 0; height: 100%; bottom: 0; top:0;"></div></td>
<td width="20%" style="padding:0;"> </td>
</tr>
</table>
This is the imageof the table
This is the call.php codes
<?php
$result = mysqli_query($conn,"SELECT * FROM job where approved='1' ORDER BY `CreatedTime` DESC");
echo "<table id='maintable' class='table-fill' border='0' cellpadding='0' cellspacing='0'>
<tr>
<th position='fixed' overflow='hidden' width='10%'>Job Title</th>
<th position='fixed' width='5%'>Company Name</th>
<th width='5%'>Closing Date</th>
</tr>";
while($row = mysqli_fetch_array($result) )
{
if (strlen($row['positiontitle']) > 20) $row['positiontitle'] = substr($row['positiontitle'], 0, 60) . "...";
echo "<tr onclick='get_data(123)' ref='job.details.php?id=".$row['id']."' target='content' class='positiontitle-link'>";
echo "<td data-id='<?php echo $row['id']?>'><font style='text-shadow: none;'>" . $row['positiontitle'] . "</font></a></td>";
echo "<td data-id='<?php echo $row['id']?>'>" . $row['companyname'] . "</td>";
echo "<td data-id='<?php echo $row['id']?>'>" . $row['closingdate'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($conn);
?>
and this is the details.php codes
<?php
$result = mysqli_query($conn,"SELECT * FROM job WHERE id = '".$_GET['id']."' ORDER BY `CreatedTime` DESC");
$jobdetails = mysqli_fetch_assoc($result);
echo ''.$jobdetails['positiontitle'].'';?>
</title>
</br>
<div style="width:100%; margin-top:-20px;">
<!-------------------------------------------Start of Right Sidebar---------------------------------------------------------------->
<div style="float:left; font-size: 14px; width:20%;"class="ara-form">
<header style="padding-top: 25px; font-size: 14px; color:#666666; padding-left:7px; padding-right:7px;">
<?php
$result = mysqli_query($conn,"SELECT * FROM job WHERE id = '".$_GET['id']."' ORDER BY `CreatedTime` DESC");
$jobdetails = mysqli_fetch_assoc($result);
echo '<strong>Job Title</strong><hr class="style-six"> '.$jobdetails['positiontitle'].'</p></br>';
echo '<strong>Company Name</strong><hr class="style-six"> '.$jobdetails['companyname'].'</p></br>';
echo '<strong>Location</strong><hr class="style-six"> '.$jobdetails['location'].'</p></br>';
echo '<strong>Closing Date</strong><hr class="style-six"> '.$jobdetails['closingdate'].'</p></br>';
echo '<strong>Number of Vacancy</strong><hr class="style-six"> '.$jobdetails['numberofvacancy'].'</p></br>';
echo '<strong>Job Category</strong><hr class="style-six"> '.$jobdetails['jobcategory'].'</p></br>';
echo '<strong>Duration</strong><hr class="style-six">'.$jobdetails['duration'].'</p></br>';
echo '<strong>Employment Type</strong><hr class="style-six"> '.$jobdetails['employmenttype'].'</p></br>';
echo '<strong>Salary</strong><hr class="style-six"> '.$jobdetails['salary'].'</p></br>';
echo '<strong>Timing</strong><hr class="style-six"> '.$jobdetails['timing'].'</p></br>';
echo '<strong>Nationality</strong><hr class="style-six"> '.$jobdetails['nationality'].'</p></br>';
echo '<strong>Gender</strong><hr class="style-six">'.$jobdetails['gender'].'</p></br>';
echo '<strong>Experience</strong><hr class="style-six">'.$jobdetails['experience'].'</p></br>';
echo '<strong>Education</strong><hr class="style-six"> '.$jobdetails['education'].'</p></br>';
echo '<strong>Gender</strong><hr class="style-six"> '.$jobdetails['gender'].'</p></br>';
echo '<strong>Gender</strong><hr class="style-six"> '.$jobdetails['gender'].'</p></br>';
?>
</header>
</div>
<!---------------------------------------------End of Right Sidebar------------------------------------------->
<div style="float:left; font-size: 14px; width:80%;" class="ara-form">
<fieldset style="font-size: 14px; color:#666666;">
<!-------------------------------------------------Start Time viewed Button------------------------------------------------>
<div style="width:100px; float:right; padding-left:2px; padding-top: 10px;">
<?php
include "module/button/job.views.php";
?>
</div>
<!---------------------------------------------------End Time viewed Button------------------------------------------------->
<!-----------------------------------------------Start Main Content----------------------------------------------->
<?php
echo '<p><strong>Company Background</strong><hr class="style-six"> '.$jobdetails['background'].'</p></br>';
echo '<p><strong>Job Summary</strong><hr class="style-six"> '.$jobdetails['summary'].'</p></br>';
echo '<p><strong>Job Duties and Responsibilities</strong><hr class="style-six"> '.$jobdetails['duty'].'</p></br>';
echo '<p><strong>Qualification</strong><hr class="style-six"> '.$jobdetails['qualification'].'</p></br>';
echo '<p><strong>Skills</strong><hr class="style-six"></br> '.$jobdetails['skill'].'</p></br>';
echo '<p><strong>Submission Guideline</strong><hr class="style-six"> '.$jobdetails['submission'].'</p></br>';
echo '<p><strong>Words to search this job</strong><hr class="style-six"> '.$jobdetails['search'].'</p></br>';
?>
<!-------------------------------------------------End Main Content----------------------------------------------->
</fieldset></div>
My Question is
1- I want to show the selected row id in the address bar
2- I want to show unclicked.php in the details div when no row selected
If you want to change the content of the address bar without refreshing the page, you'll either need to use the HTML5 History API or a hashbang URL.
HTML5 History API: This will allow you to change the content of the address bar to whatever you like, but the browser support is limited. An example is as follows:
history.pushState(null, "", "/test");
This will change the page URL to yoursite.com/test.
You can use this to add a row-related extension to the URL, eg. yoursite.com/table/row/20.
See here for a more in-depth explanation of how the API works.
Hashbang URL: This is a less clean solution, but is somewhat simpler and will work on all browsers. Your URL will look like yoursite.com/table#row20. (If you already have a # in the page URL, this will not work). Just call window.location = "#row20" to add #row20 to the current page URL.
If you are going to change the URL when a new row is selected, then you should also check the URL on page load and preselect a row if required. Eg. requesting yoursite.com/table#row20 would return the page with row 20 already selected.
$('#details').load('path/to/unclicked.php') will load the file's contents into the div. If you want this to occur on page load, just wrap it in a call to $(document).ready(). Simply make the AJAX request again if the user is able to deselect all rows.
I am trying to send selected check-box data through mail in the tables structure but getting below error:
implode(): Invalid arguments passed
static function mcontent($chkbox){
$sql = "SELECT station,reach,language,rate FROM `radio_city` where chkid in (".implode(',', $chkbox).")";
return DB::select($sql);
}
Please help.
Thanks
Jyoti
View1: this is used while sending data through mail
<input type="hidden" name="checkbox" id="checkbox" >
<input type="hidden" name="hiddamount" id="hiddamount">
<input type="email" name="email" id="email">
<input type="submit" id="submit" class="button" style="box-shadow: 5px 5px 3px #888888;" value="Email Plan" onsubmit="return validateForm();checkbox();"/>
function checkbox(){
if (document.myForm.checkbox.checked){
document.getElementById("error").innerHTML = "";
return true;
}
else {
document.getElementById("error").innerHTML = "Select your Plans";
}
}
View2: this is used while selecting checkboxes
<td onchange="Process(this.options[this.selectedIndex].value)" class="chart_row" align="center" >
<input type="checkbox" name="checkbox[<?php echo $i; ?>]" id="checkbox" value="<?php echo $chkid; ?>" data-price="<?php echo $total; ?>" onChange="updateTotal(this);">
</td>
<td id="station" class="chart_row" align="center"><?= $result->station ?></td>
<td id="reach" class="chart_row" align="center"><?= $result->reach ?></td>
<td id="language" class="chart_row" align="center"><?= $result->language ?></td>
<td id="rate" class="chart_row" align="center">Rs <?= $result->rate ?>/-</td>
<td id="duration" class="chart_row" align="center"><?= $duration ?></td>
<td id="frequency" class="chart_row" align="center"><?= $frequency ?></td>
<td id="hours" class="chart_row" align="center"><?= $hours ?></td>
<?php $totals += ($result->rate) * $duration * $frequency * $hours * $days/10; ?></div>
</tr>
Controller:
function mail() {
$input = Input::get();
if (isset($_GET['checkbox'])){
$city = $_GET['city'];
$duration = $_GET['duration'];
$frequency = $_GET['frequency'];
$hours = $_GET['hours'];
$days = $_GET['days'];
$total = $_GET['hiddamount'];
$chkbox = $_GET['checkbox'];
$mailrslt = Radio::mcontent($chkbox);
$cityname = Radio::getall($input);
foreach($cityname as $cities){
//modify table ans add css here if you want.
$html_table ="<table><caption>City: ".$cities->city."</caption><thead style='color:A0A0A0'><th width='200' align='center' class='tabledata' style='background: #f9f9f9;color: #000000;;border-bottom: 1px solid #d6d6d6;border-right: 1px solid #d6d6d6;padding: 5px 10px;'>Station</th>
<th width='200' align='center' class='tabledata' style='background: #f9f9f9;color: #000000;;border-bottom: 1px solid #d6d6d6;border-right: 1px solid #d6d6d6;padding: 5px 10px;'>Reach</th>
<th width='200' align='center' class='tabledata' style='background: #f9f9f9;color: #000000;;border-bottom: 1px solid #d6d6d6;border-right: 1px solid #d6d6d6;padding: 5px 10px;'>Language</th>
<th width='200' align='center' class='tabledata' style='background: #f9f9f9;color: #000000;;border-bottom: 1px solid #d6d6d6;border-right: 1px solid #d6d6d6;padding: 5px 10px;'>Rate</th>
<th width='200' align='center' class='tabledata' style='background: #f9f9f9;color: #000000;;border-bottom: 1px solid #d6d6d6;border-right: 1px solid #d6d6d6;padding: 5px 10px;'>Jingle Lenght</th>
<th width='200' align='center' class='tabledata' style='background: #f9f9f9;color: #000000;;border-bottom: 1px solid #d6d6d6;border-right: 1px solid #d6d6d6;padding: 5px 10px;'>Frequency</th>
<th width='200' align='center' class='tabledata' style='background: #f9f9f9;color: #000000;;border-bottom: 1px solid #d6d6d6;border-right: 1px solid #d6d6d6;padding: 5px 10px;'>Hours/Day</th>
<th width='200' align='center' class='tabledata' style='background: #f9f9f9;color: #000000;;border-bottom: 1px solid #d6d6d6;border-right: 1px solid #d6d6d6;padding: 5px 10px;'>Days/Week</th></thead><tbody style='color: #000000;'>";}
//whole query result is here
foreach($mailrslt as $key=>$row) {
$html_table .= "<tr>";
//Iterate your data for table data.
foreach($row as $key2=>$row2){
$html_table .= "<td width='200' align='center' class='tabledata'>" . $row2 . "</td>";
}
//Database data ends here
$html_table .= "<td width='200' align='center' class='tabledata'>" . $duration . "</td>";
$html_table .= "<td width='200' align='center' class='tabledata'>" . $frequency . "</td>";
$html_table .= "<td width='200' align='center' class='tabledata'>" . $hours . "</td>";
$html_table .= "<td width='200' align='center' class='tabledata'>" . $days . "</td>";
} //table rows ends here for displaying data
$html_table .= "</tr></tbody></table>";
//contact details and total calculation done here
$html_table .= "<p>The total negotiable cost for your activity is <b>Rs ".$total."/-</b></p><div float='right'></p><u><b>For Best Rates</b></u></br> Call: Samir-+919686595443</br>Email: samir#themediaant.com</p></div>";
$to = $input['email'];//user email id from form.
$from = 'help#themediaant.com';//from email ID
$subject = 'Self Help Radio Planner';//subject
$totals = 0;
$message = $html_table;//assigning html_table variable to message.
$contact_enquiry = new ContactEnquiry;
$contact_enquiry->email = $from;
$contact_enquiry->message = $message;
$contact_enquiry->save();
//final mail function goes here
$mail = Mail::send('emails.media_option_assistance', ['msg' => $message], function ($msg) use ($from, $to, $subject) {
$msg->from($from, 'The Media Ant');
$msg->to($to)->subject($subject);//->cc('servicing#themediaant.com');
});
//after successful mail redirect user to same page.
return Redirect::to('/radio-plan/radioplan')->with('message','<b>Congratulations! You have succesfully sent the email');
}
}
Model:
static function mcontent($chkbox){
$sql = "SELECT station,reach,language,rate FROM `radio_city` where chkid in (".implode(',', $chkbox).")";
return DB::select($sql);
}
Your problem is here
$chkbox = $_GET['checkbox'];
$mailrslt = Radio::mcontent($chkbox);
implode requires the second parameter (or the first if only one is supplied) to be an array. You are providing mcontent with a string that you get from the input. So when you reach implode inside mcontent, you are trying to convert a string to a string.
So you must either create an array with one or more variables to be passed to your function, or remove the implode from the function.
I would try to help more but honestly I don't understand much from your code and it would be a guessing game.
Overview
I have some data stored in MySql database related to Products. I am trying to retrieve this data and display it on a page using HTML table.
The PHP and MySql has gone well and all the data is retrieved but it is displayed in a very messy manner.
Here is what I have as a layout:
What I am aiming to achieve is to further divide the results table add more columns rows to make the data more readable
Something like this;
The code: PHP, MySQL & HTML:
<?php
session_start();
include('connect_mysql.php');
$product_name = 'product_name';
$product_qua = 'product_qua';
$product_price = 'product_price';
$product_image = 'product_image';
$product_des = 'product_des';
$sql = mysql_query("SELECT * FROM products");
echo "<table id='display'>";
while($rows = mysql_fetch_array($sql))
{
echo"<br>";
echo"<tr><td>";
echo"$rows[$product_name]<br></td>";
echo"<td><img src=$rows[$product_image] height='200px' width='200px'><br></td>";
echo"<td>Avalible: $rows[$product_qua]<br></td>";
echo"<td>Price: $rows[$product_price]<br></td>";
echo"<td>Description: $rows[$product_des]<br></td>";
echo"</tr>";
}
echo "</table>";
?>
CSS responsible for this part:
#display{
float:left;
border: 5px solid black;
margin-left:100px;
}
just add some padding or a border to the table cells:
table#display td{
border: 1px solid black;
padding:0 8px;
}
Edit: What you could do as well:
<table id='display'>
<?php while($rows = mysql_fetch_array($sql)): ?>
<!-- <br> <- why a break? it's not in the correct spot anyway -->
<tr><td>
<?php echo $rows[$product_name]; ?><br>
</td>
<td> - </td>
<td><img src="<?php echo $rows[$product_image]; ?>" height='200px' width='200px'><br></td>
<td> - </td>
<td>Avalible: <?php echo $rows[$product_qua]; ?><br></td>
<td> - </td>
<td>Price: <?php echo $rows[$product_price]; ?><br></td>
<td> - </td>
<td>Description: <?php echo $rows[$product_des]; ?><br></td>
</tr>
<?php endwhile; ?>
</table>
Tip: I prefer to use the while/endwhile; approach rather than using brackets when displaying data to the user.
First of all don't echo so much HTML using PHP, instead do it like this
<?php
session_start();
include('connect_mysql.php');
$product_name = 'product_name';
$product_qua = 'product_qua';
$product_price = 'product_price';
$product_image = 'product_image';
$product_des = 'product_des';
$sql = mysql_query("SELECT * FROM products"); ?>
<table id='display'>
<?php
while($rows = mysql_fetch_array($sql)) {
?>
<tr><td><?php echo $rows[$product_name]; ?></td>
<!-- And so on-->
<?php
}
?>
</table>
Secondly by seeing your inmage, it seems like you need a border for your table so use
table, td {
border: 1px solid #000000;
}
add the following css to apply border on your table cells:
#display td{ border: 2px solid red; }
and optionally add to your #display { :
border-collapse: collapse;
i want to replace all between <p> tags with a simple word NotFound
<p id='2'>
<?php
foreach ($d as $key=>$value)
{
extract($value);
if($key%4==0)
{
echo "</tr>";
echo"<tr>";
}
include('item.php');
}
echo"</table>";
echo"</div>";
?>
</p>
how can i do that using javaScript??
update:
i used that code in the javascript area:
<script type="text/javascript">
window.onload=msg;
function msg(){
document.getElementById('1').onclick=clickhandlee;
//
}
function clickhandlee(){
var ps = document.getElementsByTagName('p');
for(var i=0, max=ps.length; i<max; i++){
ps[i].innerHTML = "NotFound";
}
}
</script>
and the same previous code in the <body> tags
<p id='2'>
<?php
foreach ($d as $key=>$value)
{
extract($value);
if($key%4==0)
{
echo "</tr>";
echo"<tr>";
}
include('item.php');
}
echo"</table>";
echo"</div>";
?>
</p>
this is the included php template item.php
<td style='border: 0px none ; margin: 0px; padding: 0px; width: 240px;' align='right' valign='top'>
<div style='margin-bottom: 10px;'>
<table class='topic' border='0' cellpadding='0' cellspacing='0' align='right'>
<tbody>
<tr>
<td style='background: url('style/$style/images/top_background.jpg') no-repeat left center; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous' align='center' height='35'>
<div style='overflow: hidden; width: 230px;'>
<a class='link' href='t<?=$id;?>-<?=$name;?>.html'>
<?=$name;?> </a>
</div>
</td>
</tr>
<tr>
<td align='center' style="height: 197px">
<a href='count-<?=$id;?>;.html'>
<img src='<?=$photo;?>' class='image' border='0' width='220' height='170'/></a>
<div dir='rtl' class='shortdes'><?=$shortdes;?></div>
</td>
</tr>
<tr valign='top'>
<td style='background: url('style/$style/images/footer_background.jpg') no-repeat left center; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; height: 29px;' align='center' height='35'>
<a class='dlink' href='count-<?=$id;?>.html'>
<div class='download' style="height: 17px">
التحميل : <?=$visits;?>
</div></a>
</td>
</tr>
</tbody>
</table>
</div>
</td>
var paragraphs = document.getElementsByTagName('p'),
i = paragraphs.length;
while (i--)
{
paragraphs[i].innerHTML = 'NotFound';
}
Using Javascript:
var ps = document.getElementsByTagName('p');
for(var i=0, max=ps.length; i<max; i++)
ps[i].innerHTML = "NotFound";
Using Javascript
Note comment by user DA - IDs cannot start with a number before HTML 5, so assume that the ID is spelled out (two) instead of the numeral (2) if not using HTML 5.
If it is only for the <p> tag with id=two:
document.getElementById("two").innerHTML = "NotFound";
If it is for all <p> tags:
var paragraphs = document.getElementsByTagName("p");
for(var i = 0; i < paragraphs.length; i++) {
paragraphs[i].innerHTML = "NotFound";
}
The key is the innerHTML tag of the DOM elements.
If you're using jquery: $('p').html('NotFound');