i created a news panel where we use this code for displaying news :
<marquee direction="up" >
<?php
$query = $this->db->get('news');
foreach ($query->result() as $row)
{
echo $row->news;
echo $row->urladdress;
echo '<br/>';
}
?>
</marquee>
where it show correct , all data get fetched and run marquee good ,
but we tried ,when we click on news then it go urladdress , which fetch from table . By using this code but not work -
<marquee direction="up" >
<?php
$query = $this->db->get('student');
foreach ($query->result() as $row)
{
echo $row->news;
echo $row->urladdress;
echo 'click here';
echo '<br/>';
}
</marquee>
Read CI anchor
echo anchor($row->urladdress, 'click here', 'title="click here"');
its "" not '' to echo value of field
echo "<a href='$row->urladdress'>click here</a>";
OR
echo 'click here';
<marquee direction="up" >
<?php
$query = $this->db->get('student');
foreach ($query->result() as $row)
{
echo $row->news;
echo $row->urladdress;
echo 'click here';
echo '<br/>';
}
?>
Related
I'm working on a search function of a flat HTML site and I've got it working but I want to add the page link to the results so people can navigate there but the page_link column won't appear next to it how can I make it appear?
if(isset($_GET['keywords'])) {
$keywords = $dbc->escape_string($_GET['keywords']);
$query = $dbc->query("
SELECT page_title
FROM contents
WHERE page_contents LIKE '%{$keywords}%'
OR page_title LIKE '%{$keywords}%'
");
}
?>
<div class="result-count">
Found <?php echo $query->num_rows; ?> result(s).
</div>
<?php
if($query->num_rows) {
while($r = $query->fetch_object()) {
?>
<div class="result">
<?php
echo $r->page_title, $r->page_link;
?>
</div>
<?php
}
<?php
echo '<a href=' . $r->page_link . '>' . $r->page_title . '</a>;
?>
I use osclass and I have this code for display regions and their cities. All working good but I need display regions and cities only with items, how can i do it? Please help me i'm beginner.
<?php
$aRegions = Region::newInstance()->getByCountry('AT');
if(count($aRegions) > 0 ) {
?>
<ul>
<?php
foreach($aRegions as $region) {
//print_r ($region);
echo "<li>";
//$region['pk_i_id'].
?>
<div class="accordionButton">
<a href="javascript:void()">
<?php echo $region['s_name']."\n"; ?>
</a>
<?php // echo "</em>(". $region['items'].")</em>";?>
</div>
<?php
$aCities = City::newInstance()-> getByRegion($region['pk_i_id']);
if(count($aCities) > 0 ) {
echo "<div class=\"accordionContent\">";
echo "<ul>";
foreach($aCities as $city) {
// print_r ($city);
//$city["pk_i_id"].'
echo "<li>";
echo "<a href='". osc_search_url( array( 'sRegion'=>$region["s_name"], 'sCity' => $city['s_name'] ) ) ."'> ";
echo $city["s_name"]."\n";
echo "</em>(". $city['items'].")</em>";
echo "</a>";
echo "</li>";
}
}
echo "</ul>";
echo "</li>";
}
?>
This is just a thought i have for my project is it possible to use a string for example an echo as parameter for select statement in database query?
here is the scenario:
For example when my page loads i automatically display the latest data in database say last five entry, as echo of course. and for each entry there are other details and in order to view those other details i will have an anchor for each echo and i will direct the user to another page..using the echo i want to query the database for other details..
Is this possible?
I know I cant put attribute name to echo so how is this possible?
Any suggestions?
Update
this is the page that will show the echo
<form method="POST" action="crud.php" enctype="multipart/form-data" >
<div class="headerimage"><img src="images/events.png"/></div>
<?php
foreach (LoadEvent() as $value){
echo '<div id="upcomingevent">';
//echo "<a href=\"#\" >".$value['searchresultwhat']."</a>";
echo "".$value['searchresultwhat']."";
echo "<input type='hidden' name=\"eventwhatcontent\" value=".$value['searchresultwhat'].">";
echo "<br/>\n";
echo $value['searchresultwhen'];
echo "<br/>\n";
echo $value['searchresultwhere'];
echo '</div>';
}
?>
</form>
then this is the method and the page where i must display the details of the event
<form method="POST" action="crud.php" enctype="multipart/form-data" >
<?php
echo '<div id="middlecontentupcomingevents">';
LoadSpecificEvent();
echo '<div id="upcomingeventcontentimage">';
echo "<img src=\"admin/".$events[4]."\">";
echo $events[0];
echo $events[1];
echo $events[2];
echo $events[3];
echo '</div>';
echo "<br/>\n";
echo '</div>';
echo '</div>';
?>
</form>
function LoadSpecificEvent(){
global $dbh;
//var_dump($dbh);
if (isset($_POST['eventwhatcontent'])) {
$eventwhat = $_POST['eventwhatcontent'];
$stmt = $dbh->prepare("SELECT * FROM events WHERE event_what = ?");
$stmt->bindValue(1,$eventwhat);
$stmt->execute();
$events = array();
$selected_row = $stmt->fetch(PDO::FETCH_ASSOC);
$events[] = array(
'searchresultwhat' => $selected_row['event_what'],
'searchresultwhere' => $selected_row['event_where'],
'searchresultwhen' => $selected_row['event_when'],
'searchresultwho' => $selected_row['event_who'],
'searchresultimg' => $selected_row['img_url']
);
print_r ($events);
return $events;
}
}
Hi I would like to order custom fields in wordpress. I've got it displaying the single project. But can't figure out how I can get it to display in order. I've created a field called project_order which works correctly on another page.
But i'm not used to this sort of php with order by. This is a project designed by someone else so i'm trying to pick up and learn how it was built.
<?php
//associate sector to product projects page
$sector['construction'] = 131;
$sector['timber-frame'] = 235;
$sector['industrial'] = 253;
$sector['agriculture'] = 263;
//link to view all projects for product
echo '<p>View all projects</p>';
?>
</div>
<div class="span5">
<div id="latestproject">
<h2>Latest Project</h2>
<?php
//get latest projects
$rows = get_field('projects', $sector [$post->post_name] , '&order=ASC');
//display latest project
if ($rows) {
echo '<div class="row">';
if ($rows[0]['project_pageturner']) {
echo '<a href="'.$rows[0]['project_pageturner'].'" target="_blank">';
} else if ($rows[0]['project_pdf']) {
echo '<a href="'.wp_get_attachment_url($rows[0]['project_pdf']).'" target="_blank">';
} else {
echo "<a href=\"javascript:alert('No PDF uploaded for this item.')\">";
}
echo '<div class="span2">';
if ($rows[0]['project_thumbnail']) {
echo wp_get_attachment_image($rows[0]['project_thumbnail'], 'full');
} else {
echo '<img src="'.get_bloginfo('template_directory').'/images/defaultproject.jpg" alt="">';
}
echo '</div>';
echo '<div class="span3">';
echo '<p><strong>'.$rows[0]['project_title'].'</strong></p>';
echo '<p>View project »</p>';
echo '</div>';
echo '</a>';
echo '</div><!--row-->';
} else {
echo '<p>No projects to display currently.</p>';
}
?>
I'm guessing it will have something to do with.
$rows = get_field('projects', $sector [$post->post_name]);
Try below code, may be this resolve your problem.
<?php
wp_reset_query();
//associate sector to product projects page
$sector['construction'] = 131;
$sector['timber-frame'] = 235;
$sector['industrial'] = 253;
$sector['agriculture'] = 263;
//link to view all projects for product
echo '<p>View all projects</p>';
?>
</div>
<div class="span5">
<div id="latestproject">
<h2>Latest Project</h2>
<?php
//get latest projects
$rows = get_field('projects', $sector [$post->post_name] , '&order=ASC');
//display latest project
if ($rows) {
echo '<div class="row">';
if ($rows[0]['project_pageturner']) {
echo '<a href="'.$rows[0]['project_pageturner'].'" target="_blank">';
} else if ($rows[0]['project_pdf']) {
echo '<a href="'.wp_get_attachment_url($rows[0]['project_pdf']).'" target="_blank">';
} else {
echo "<a href=\"javascript:alert('No PDF uploaded for this item.')\">";
}
echo '<div class="span2">';
if ($rows[0]['project_thumbnail']) {
echo wp_get_attachment_image($rows[0]['project_thumbnail'], 'full');
} else {
echo '<img src="'.get_bloginfo('template_directory').'/images/defaultproject.jpg" alt="">';
}
echo '</div>';
echo '<div class="span3">';
echo '<p><strong>'.$rows[0]['project_title'].'</strong></p>';
echo '<p>View project »</p>';
echo '</div>';
echo '</a>';
echo '</div><!--row-->';
} else {
echo '<p>No projects to display currently.</p>';
}
wp_reset_query();
?>
Thanks.
I have this code which produces me a number which is equal to the number of id's i've got in my database of star rating system.
This code generates me a five star voting for each id i've got, but the problem is, it generates them all in a div, while i need them specifically in different div's. let's suppose i print out in a div information for each hostess i've got, i print out their photo and name with the following code:
$sql =" select * from hostess";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
echo "<div id='photo'>";
echo "<div id='picture'>";
echo "<div id='scotch'><img src='images/Scotch.png'></div>";
echo "<td> <img src=foto/photo1/".$row['photo'] . "></td>";
echo "</div>";
echo "<div id='text'>";
echo '<td>'. $row['first_name_en']." ". $row['family_name_en']."</td>";
echo "</div>";
echo "</div>";
echo "<div id='photo2'>";
echo "<div id='picture'>";
echo "<div id='notes'>";
echo '<form action="index.php" method="post" >';
echo "<label>Notes</label></br><textarea>".$row['courrent_occupation'] . "</textarea></br>";
echo '<input type="submit" value="edit" name="edit"></div>';
echo "</div>";
echo "<div id='notes'>";
echo "<label>profile</label></br><textarea>".$row['profile_en'] . "</textarea>";
echo "</div>";
echo "</div>";
}
?>
</div>
Now, i've got this other php which generates me all the star ratings for all hostess id's
<?php
// include update.php
include_once 'update.php';
// get all data from tabel
$arr_star = fetchStar();
?>
<?php
// start looping datas
foreach($arr_star as $star){ ?>
<h2>Star Rater - <?php echo $star['id'];?></h2>
<ul class='star-rating' id="star-rating-<?php echo $star['id'];?>">
<?php /* getRating($id) is to generate current rating */?>
<li class="current-rating" id="current-rating-<?php echo $star['id'];?>" style="width:<?php echo getRating($star['id'])?>%"><!-- will show current rating --></li>
<?php
/* we need to generate 'id' for star rating.. this 'id' will identify which data to execute */
/* we will pass it in ajax later */
?>
<span class="ratelinks" id="<?php echo $star['id'];?>">
<li>1</li>
<li>1.5</li>
<li>2</li>
<li>2.5</li>
<li>3</li>
<li>3.5</li>
<li>4</li>
<li>4.5</li>
<li>5</li>
</span>
</ul>
<?php } ?>
What i need is to assign each hostess profile i print their system rating.
I try to insert the foreach inside the first script but it then shows me just one profile, not all profiles.
The fetchstar() code is:
function fetchStar(){
$sql = "select * from `hostess`";
$result=#mysql_query($sql);
while($rs = #mysql_fetch_array($result,MYSQL_ASSOC)){
$arr_data[] = $rs;
}
return $arr_data;
}
First, you probably shouldn't use SELECT *. That aside I would combine the two queries you have to return a multidimensional array with MySQL and then use nested for each loops to echo out the data you want.
Someone answered a similar question for me here.
Looping through MySQL left join in php vs. 2 separate queries
$sql =" select * from hostess";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
if ($lastID <> $row['id']) {
$lastID = $row['id'];
$hostess[$lastID] = array('id' => $row['id'],
'first_name_en' => $row['first_name_en'],
etc
'arr_star' => array() );
}
$hostess[$lastID]['arr_star'][] = array('star_id' => $row['star_id'] etc);
}
Then you would use nested for each statements
for each($row as $rows){
//echo your hostess information
for each ($arr_star as $star){
//echo your star rating information
}
}