Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Gathering Results And Echoing Them As One?


I'm trying to display all the results from a database and use echo them using $total.

$total =     do {  "".$row_use['lon']." ".$row_use['lat'].""  } while ($row_use = mysql_fetch_assoc($use));

echo $total;

I was wondering why does that not work?  How do I get the php repeated regions to work?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Strange Results Echoing '£'
I'm getting a very strange result trying to echo a simple pound sign '£'. Here's my code:

$currency = '£';
echo $currency;
For some reason it's outputting this:
£With the Â...

I've tried this as well: echo htmlentities($currency)but I get the same result.. I've never had this problem before and it doesn't6 happen with any other symbols, could anyone suggest an answer?

Gathering From Txt File
ive created alot of javascript functions for my mmorpg.. (eg. fishing, fighting) where players select options rather then just get the results of what happend (more intresting this way)

after the functions are finnished i insert the variables into a txt file, one problem im having is i want to insert it into my mysql database. im planing to include a file on every page that will gather the info and store it into the database.

PHP Script For Gathering Form Data Without FP Extensions?
Is there a PHP script that I can "infuse" into a feedback or registration form that I have created in Front Page 2000, that I can use on a server without FP extensions that would allow me to gather the data into a hidden folder or be routed to an "MS Access" database?

I am fairly new to PHP, but I know I would have to delete all those bothersome "webbot" scripting entries from the form first but can anyone please give me a jump start?

Echoing Sql
Another good thing to do would be to set the sql statement equal to a variable instead of just inside of the mysql_query() function. PHP Code:

Echoing Image
form action="index.php#order" method="post" name="image1" id="image1">
<input name="image1" type="submit" id="image1" value="Buy!">

form action="index.php#order" method="post" name="image2" id="image2">
<input name="image2" type="submit" id="image3" value="Buy!">

<form name="form1" method="post" action="thankyou.php">

<?php
if ($_POST[image1]) {
echo "<img src="image/image1.jpg">";
}
if ($_POST[image2]) {
echo "<img src="image/image2.jpg">";
}
?>

Problem Echoing
If I set a varaible as

$EOL = "
"

But then want to echo that to a HTML page to see the above string
i.e.

by doing: echo($EOL);

How do I do it?

I've tried quotemeta, addslashes and htmlspecialchar
but can't seem to work it out.

Echoing An '&' Character?
I'm trying to figure out how to include an '&' character in a php echo. I'm not looking for the html & a m p ; special character, but the actual character, since i'm trying to do this: Code:

echo "<A HREF"/download.php?type=wallpaper&file=$filename">Download</A>";

instead it returns a link such as this: Code:

/download.php?type=wallpaperfile=wallpaper.zip

Echoing Php In A Textfield
when i echo out text from mysql in a text area field it also echoes out the line breaks e.g it doesn't happen if i echo out anywhere else on the page, could i do a preg_replace to make all the line breaks echo NULL? Code:

Echoing Codes
I have a simple script for an IFrame for my forum page...

<?php if(!isset($_GET['post'])){ echo '<iframe src="/forum/" name="fleet" width="800" height="auto" scrolling="no" frameborder="no" id="fleet"> Your browser does not support inline frames or is currently configured not to display inline frames. </iframe>'; }else{
 echo '<iframe src="/forum/viewtopic.php?p='.$_GET['post'].'" name="fleet" width="800" height="auto" scrolling="no" frameborder="no" id="fleet"> Your browser does not support inline frames or is currently configured not to display inline frames. </iframe>';} ?>

Whenever I open the page, it does not automatically expand to the framed page height, how can I fix this...?

Echoing Out A While In A Table
i use this while loop to echout all my categories at once, but is there a way i could have them echo out in a table say 5 across at a time? Code:

Echoing Value To List Menu
Hi, I was wondering can I echo out value from db to list menu and how?

Echoing Strings With Quotemarks?
I have a statement that gives me an error:

echo "<table><tr><td>Title</td><td>Author</td><td>Date added</td><td>Hits</td></tr><tr><td><a href="test">$arttitle</a></td><td>$artauthor (<a href=/"mailto:$artauthoremail/">)</td><td>$artcreationdate</td><td>$arthits</td></tr></table><br>";


Parse error: parse error, unexpected T_STRING, expecting ',' or '' in /home/hsphere/local/home/cmwong/singaporeanimenews.net/mm-article.php on line 299


backslashing the quotemarks continues giving the error. How might I get around this?

Echoing Variables Into HTML
So I'm playing with a very retarded list of products 1-9, and have the
following list.php page snippet excluding html header/footers/table tags:

Echoing PHP Code From A Database?
I have the following data in a MySQL database:
<a href="<?php echo $server; ?>Sugapablo-Stick_It_To_The_Man.mp3"

let's call it $row[0].

when I echo $row[0], the php code is shown as opposed to the value of
$server.

How can I get the value of $server to appear? str_replace?

Php/mysql Echoing Same Thing Twice--help!
I'm just learning php and set up a sample mysql db to practice with. I
have the following script and cannot for the life of me figure out why
it is printing each field of the row twice? I checked my db and it only
contains the entries once. What is causing this?!

-----------------------------------------------------------------------
<?php
$con_id = mysql_connect('localhost','dboard_mbr','pa1ss2wo3r d');

mysql_select_db('kp_dboard',$con_id);

echo join(mysql_fetch_array($thequery=mysql_query('sele ct * from
threads',$con_id)),' --- ') . '<br>'

echo join(mysql_fetch_array($thequery),' --- ') . '<br>'

echo join(mysql_fetch_array($thequery),' --- ');
?>
-----------------------------------------------------------------------

Echoing The Correct XML Tag Data
I am having trouble ECHOing specific data and for some reason the links for each sub parent are combined into one link...Let me explain that. The first link is correct and outputs http://example.com/1, but the second link outputs http://example.com/1http://example.com/2

Does anyone know why that is? The other problem I have is that I have about 200 sub parents in my xml file and the sub parents represent different categories, for example: Code:

Join And Echoing Correct Id
The information is displayed correctly.  The problem comes into play with the record id's. 

The link I would click on for the employees name is echoing the job id and not the employee id so I get sent to the job page and not the employee profile.  The link I would click on for the job is echoing fine. Code:

Echoing Multiple Arrays
I have a products table that I want to echo the results of 3 different categories, I can query the db just fine and get results for a single category, but I'm a newb to PHP and don't know the trick way to do slick recursion. Code:

Echoing A Variable Which Isn't Set Until Later In The File?
I could have sworn this was possible somehow, but it isn't working for me... Let's say I have a line at the top of my file, which is echo "$links". Then, the variable $links is set further down in the file, depending on some SQL results and GET variables.

For me, even though I'm setting $links in the file, it will only echo if it's set before it's echoed. It make sense, but I have a definete memory that I once had a way around that problem - anyone know how to do it? Code:

Setting Headers And Echoing Images
My scenario is that I am trying to put an image on a page using php not on my server, that does not have php. I am using the tag <img src=http://myserver.com/asdf.php3> and asdf will a) read an image b) set a header("Content-type: image/gif") and c) echo the image. That works fine.
The problem is that I also wanted to include a link based on the image (ie - dynamic, involving php). After I set the header, regular tags are ignored and I can't echo anything before a header, nor can I set a different header.
SO my question is, does anyone know a workaround to this problem: like displaying an image on a non-server page, without setting a header, or a way to dynamical reference something? Any help is greatly appreciated and if you think you might be able to help, but don't understand my situation or need clarification, contact me.

PS - If it can't be done with PHP, can it be done with any other language anyone knows of?

Time - Echoing It Back Differently
I have a datetime column setup in a mysql database. My web host, which i based in Hawaii, has a different time zone to that of mine over her in good old England. I was wondering is there a way of echoing out the time from the datetime column but adding on 9 hours more?? Or even would it be easier to submit the data into the database with the time difference?

Echoing 3 Types Of Data From 1 Table Row
I have this script where one of the rows in a mysql table is named "type" tinyint(3).

now when a person joins the site they have a basic membership and their data is 0 in the type row when they become silver members it is 1 and gold is 2 all 3 numbers are entered into that one row for each member depending on what kind of membership they have.

what I want to do is echo each type of membership on a page by the total number of each type so say there is 100 basic memberships then it would add up all the 0's within the row in the mysql database and then echo that total. I have already gotten it to display total number of users by adding. Code:

$query = "select id from user";
$result = MYSQL_QUERY($query);
$totalusers=mysql_num_rows($result);
@mysql_free_result($result);
if(($s=="")or($s>=$totalusers)or($s<0)){
$s=0;}

and then having <?print $totalusers;?> where ever I want it to echo. How can I do the same with the memberships? I have a feeling that it would have something to do with $totalusers=mysql_num_rows($result); i need to change mysql_num_rows to something else?

Selective Echoing And Database Select
I have written a search engine for business listings for the company I work for. Each listing is in a database, and that works fine. The problem though is two-fold.

The first part of the problem is that not all listings utilise every column of the database, and this leaves gaps when echoing the results. This is not what i had in mind, Any ideas/help would be appreciated.

The second part of the problem is related to the first in that there is a link for any listing that has a website, but not every listing has a website, so every listing having a "Visit our Site" link is impractical and shoddy. Also, i'm not sure how to echo the url from the database effectively in the first place.

Echoing Multiple Html Tables
im trying to echo out multiple results from a database and returning them in a table. Each new row in the database leads should lead to a new row in the HTML table. However I can only get it so the first row from the database goes into the html table as it should, the rest go outside it. Any ideas? Code:

Echoing Users Data From Mysql
when users on my site look at they're profile details some of the data in like this:

<select name="somename">
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
</select>

once a user has selected an option and it's stored in mysql i was wanting the specific information to be displayed in the drop down box, if i selected option 2 next time i log in option 2 is displayed and so on. what would be the best way to achieve this?

Is_dir() And Opendir() - Detecting Sub_directories And Echoing Them?
I am working on a single script to:

1) create a menu of directories containing photos (jump to script below)
2) output all the thumbnails of each photo (linked to photo itself) within each linked directory

I have step 2 solved. However, as I was about to solve step 1, I mucked up my code so badly I lost it. I simply want to output all the sub_directory names within a directory.

my structure is as follows:

../images/photos/group
../images/photos/sports
../images/photos/outdoors
etc.

The script itself is currently located in the images directory but could also be located in the photos directory as I want to detect all sub_directories of photos. Here is the part of the script that is supposed to do what I want in step 1. PHP Code:

Not Echoing A Variable If It Exists In A MySQL Table
I have a variable $mydate which loops for all the days of a month (in a while loop), so therefore for April its:

01042007
02042007
03042007, etc...

I also have a MySQL table "bookings", which contains the field "date". This field is populated with rows of dates, with the same format as those in $mydate (eg. 01042007)
Is there any way to not echo $mydate if it exists as one of the entries in the "date" field in the database?

Search Brings Back Different Results Or Sometimes No Results
The problem Iv got is that when searching the site - it brings back different results or sometimes no results. For example: "i026", "i 026" and "026" do not bring back results for "I-026" which is the correct model number. Any ideas on how to make it search more variations or of a "Did you mean... I-026" script?

Search Results ($num_rows) Does Not Match $search Results (PHP,MySQL)?
For example, when I do a database search for a term I get 2 results but the $num_rows says there are 3 results.

I suspect it's because there are similar keywords within different search fields of the SQL statement. But I am stumped as to how I can change this. Any Suggestions? the code:

Php Echoing Javascript With Php Within The Javascript
I'm echoing a bit of javascript within php which itself has some php within it. I'm having trouble inserting the items properly that are surrounded by the***********. The *********** are not part of the code they are there just to point out the troubled spots.

If I replace '. $Recordset5->Fields('col1b').' and .echo strtoupper($Recordset5->Fields('col2b')). with normal text it works fine. I think my syntax or quotes are incorrect for inputting the dynamic php content within the javascript.....

How To Add A <br> After 3 Results?
I am wondering if anyone could help me solve this issue. I am using a foreach loop and i would like to add a line break after three records then repeat the process.

Example:

foreach($array as $v){
echo $v.' ';}

In that example, it will display ( apples oranges banana pumpkin turnips pineapple beer pepsi) How do i get it to display:

apples oranges banana
pumpkin turnips pineapple
beer pepsi etc....

Notice above that after each three results the next three are placed on a new line. How can I accomplish that with my loop.

Getting Results Twice?
I am having a small problem. I have a small script which gets a METAR feed, processes it and then displays the weather information. The problem is that it will accept 1 weather station as an input variable.

How can I run this script TWICE within the same execution, while getting 2 results, using 2 different weather stations? The main file uses this to execute the functions which are on another separate file: Code:

Splitting Up Results
I have a large database and would like to split the results into 20 per page and with arrows to go to the next page and numbers to skip pages. But I'm not sure how to do it. I know I've seen an article on how to do this somewhere, anyone know one about this?

Is This Possible With Search Results
Is it possible that when someone does a search on your database, that the results are downloaded as a text file?

Grabbing Only First Var From Results
I'm working on a calendar program that I inherited from a sick Webmaster somewhere in the world. Below is part of the code that chooses and compares dates to print on the calendar. The part in bold is what I think is going to be the key to solving my problem, I just don't know how to go about it.

The 'dates' column for a record in the 'programs' look like this: &62&74&84&90, etc.

Each number represents a date with more details in the 'dates' table.
Echoing out $datenum will give one number like &#3963;'. The problem is I want only first date and to ignore the rest per record. The SQL looks like this. Is it possible to only get the first search result of date per record?

foreach ($chosen_dates as $c) {
if ($c['day'] == $day_num) {
if ($section == false) { // This runs for printing courses and not programs
$coursenum = $c['coursenum'];
$name = mysql_query("SELECT name FROM courses WHERE keyword='$coursenum'");

$name_row = mysql_fetch_object($name);
// if there are courses for this $day_num

print "<p><a href='course.php?index=".$c['coursenum']."'
";

print "title='".$c['stime']."-".$c['etime']." ".$c['section']."'>".$name_row->name."</a></p>
";
}
else { // This runs to print programs and not courses.

$datenum = $c['datenum'];
echo "Datenum=$datenum";

$date_search = mysql_query("SELECT num, dates, category FROM programs WHERE dates REGEXP '&$datenum&'");

$date_found = mysql_num_rows($date_search);
//echo "Number of dates found = ".$date_found;

if ($date_found > 0) {
while($row = mysql_fetch_object($date_search)) {
//echo $c['section'] ." ";
//echo "cat= ". $row->num;
foreach($isPrinted as $printed){
if(!in_array(array('section'=>$c['section'], 'courseNum'=>$row->num), $isPrinted)){
print "<p><a href='program.php?index=".$row->num."'
";
print "title='".$c['stime']."-".$c['etime']." ".$c['section']."'>".$row->category."</a></p>
";
$isPrinted[] = array('section'=>$c['section'], 'courseNum'=>$row->num);
break;
}

}
}...

Is there such thing as maybe using a LIMIT with this kind of SQL statement? The one above is:SELECT num, dates, category FROM programs WHERE dates REGEXP '&$datenum&

Could you use something to the effect of:
SELECT num, dates, category FROM programs WHERE dates REGEXP '&$datenum& LIMIT 1?

Listing Results From DB
Anyway I have a wee problem: what I have is a javascript popup with two values passed through: PHP Code:

Results Into A Matrix Using Php?
I've been trying to work out how to insert results from a database query into a two-dimensional matrix using php.
We used a star schema for our datawarehouse. Thus we have a price fact table and we need to perform aggregate functions on this table. This part is relatively simple.
I've managed to connect to the oracle database and retrieve the data but only display the results in a normal table. What I'd like to do is display the results in a matrix so that I can avoid repeating fields. For instance if there are three variables: Code:

Checkboxes And Sql Row Results
I am trying to place a checkbox beside each row that is inputed into the database.

Now this is how I diplay the rows:
print "<br><br>There are $num_rows records.<P>";
print "<table width=500 border=0>
";
while ($get_info = mysql_fetch_row($result)) {
print "<tr>
";
foreach ($get_info as $field)
print " <td><font face=arial size=1/>$field</font></td>
";
print "</tr>
";

How would I go about attaching this:
<input type="checkbox" value="..." name="...">
to the side of each displayed row? Also, how would I assign the row id to the checkbox so that once the box is check and the action initiated the row would be deleted?

Returning Results With An '
I am using this script

$mresult = mysql_query("SELECT DISTINCT game FROM vids order by id desc limit 50", $link) or die ("query 1: " . mysql_error());

while ($mrow = mysql_fetch_array($mresult))
{
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM vids where game = '$mrow[game]'"), 0);
}

but for any $mrow[game] that has an ' in it a 0 is returned, how do I fix this?

Getting Bad Results From Fsocketopen
If I send this to the server:

POST /errors/index.htm HTTP/1.1
Host: www.publicdomainsoftware.org
Content-Type: application/x-www-form-urlencoded
Content-Length: 1200
%3C%2Fdiv%3E

Why do I get this back:

HTTP/1.1 400 Bad Request Date: Fri, 12 May 2006 02:37:43 GMT Server:
Apache/2.0.46 (Red Hat) Content-Length: 302 Connection: close
Content-Type: text/html; charset=iso-8859-1
Bad Request
Your browser sent a request that this server could not understand.
Apache/2.0.46 (Red Hat) Server at default Port 80

Sorting XML Results
The following code parses an XML file and displays the results. The function resultSort is meant to sort the results by price from highest to lowest. Unfortunately, it's not sorting correctly in all cases. I think this may be due to the prices being in euros. Right now, this is how it outputs the results:


1 208,00
2 148,00
412,00
638,00
942,00

This is how it should look:

2 148,00
1 208,00
942,00
638,00
412,00

Here's the code: PHP Code:

PHP - Sending Results
I am looking for a simple form Processor that will send the results to a defined user, but at the same time send these same results to the user that filled it out. This sounds simple enough I realized, but to be honest I can't seem to find anything that will easily allow me to do this and use my own HTML based inputs at the same time.

Sorting Results
I hava a table with a primary key cod_topico and I'd sort my results.
I do this, ok?
$query='SELECT * from topico order by cod_topico asc' ;
But I would not sorting asc, How I sort a non-asc form? What is the oposite of asc?

Percentage Of Results
I have a table with various colums that I would like to display some stastisics. For example on colum is Gender. It holds either Male or Female. How can I output the percentage of each? ie... Female = 80% Male = 20%

Saving Php Results
I have an html code which contains callings to a php script which generates JPEG images
via GD library. When I select 'save as' in any browser two options are given (.html or .txt) but none of them allows to save the page as it is shown in the browser (with images). Where images should be there are only empty links....Does anyone have an idea about it?

Looping Results...
I'm writing a simple display page for a bunch of info from a realestate database as an exercise. I've successfully queried and displayed the information in tables, but I want it to keep pulling information from the tables until there are no more left. What i've got only pulls one entry. Code:

Getting Too Many Results From A Query!
This is very peculiar -- for some reason, I'm getting 6-8 results from each
of these queries, although only one listing matches. I have a pair of forms
on one page:

<FORM>
Search for lastname: ____________ [Submit]
</FORM>
<FORM>
Search for email: ________________ [Submit]
</FORM>

This goes to a searchresults.php page:

if ($searchname !== "") {
$query="SELECT artistID,firstname,lastname,email,city,state,count ry
from artists WHERE lastname='$searchname'";
$result=mysql_query($query) or die(mysql_error("Could not execute
query."));
while($row = mysql_fetch_array($result)) {
$alt_artistID = $row['artistID'];
$alt_firstname = $row['firstname'];
$alt_lastname= $row['lastname'];
$alt_email = $row['email'];
$alt_city = $row['city'];
$alt_state = $row['state'];
$alt_country = $row['country'];
echo "<CENTER><HR>".$alt_artistID."<BR>"
.$alt_firstname." ".$alt_lastname."</A><BR>"
.$alt_email."<BR>"
.$alt_city.", ".$alt_state." ".$alt_country."<BR>
<A HREF=delete.php?aritstID=".$alt_artistID.">DELETE THIS
LISTING?</A><BR></CENTER>";
}
}

The second section is identical except for:
if ($searchemail !== "") {
$query="SELECT artistID,firstname,lastname,email,city,state,count ry
from artists WHERE email='$searchemail'";
etc...
}

I don't understand why I would get 6-8 records when you can look at them and
see that all but one clearly do not match...?

Paging Through Results
Does anyone have or know of a nice PHP class or code to page through a set of results drawn from mysql? ie to display the list of results in 'pagefuls' with a nav bar like: Code:

[1] [2] >3< [4] [5] where &#393;' is the current page, and the other numbers are links to the other pages...? I know this has been covered a few times on this forum, but I can't for the life of me find any of the threads searching on 'pager' or 'pagination'.

Confusing >> Results
Using >> normally shifts bits to the right x number of times, where x
is specified by the programmer. As an example, 0x40000000 >> 8 yields
0x00400000. This makes me wonder... why doesn't the same thing happen
with 0x80000000 >> 8? The number it yields is 0xff800000 - not
0x00800000. The following script better demonstrates this:

<?
echo sprintf('%08x',0x40000000 >> 8)."
";
echo sprintf('%08x',0x80000000 >> 8);
?>


Copyright © 2005-08 www.BigResource.com, All rights reserved