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




Display Only Mysql_num_rows Results #-# (or Similar)


I have this mysql database. It works great, the stuff outputs how I want. But I'm making a news website and I need to change the articles each month.

I'm putting all the articles into one database, then into each page as tables (ie: news, opinion, sports, etc.), then the articles each have their own row. On the homepage here it outputs all 5 articles from the news table, but I only want it to output result numbers (blah) through (whatever). Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Similar Search Results - FULLTEXT Or Algorithm
first of all I'm sure that what I want to do isn't going to be easy...

I'd like to be able to take user input and query the database to return
exact and similar results. I have added a FULLTEXT index of the column I
want to search to the table. Then taking user input and break it apart into
separate words and use something like:

MATCH (table) AGAINST ('*word1*' '*word2*' IN BOOLEAN MODE) AS Score

in my SELECT and then ORDER BY Score DESC and that works pretty good, but
I'd like to factor in misspellings, abbreviations, etc. I have searched to
see if I could find code for an existing algorithm that I could try, but all
I have found are articles talking about different algorithms and no actual
code.

Display Results
I have created a form where the number of rows are displayed based on a value from a select box. Everything works excellent this far. however I need to take it to the next step where I display the information back into the form based on values in a mysql table. Code:

Categorical Results Display
I want to take these results and display them by category. I.e. each of these results would fall into different categories like "insurance", they are maked in the database simply with a "Y" for each category that they would appear in. I could make a page like this for each of the 20 categories, but I am sure there is a better way.
<?
if(!IsSet($start))
$start = 0;
$result = mysql_query("SELECT site_name, site_address, site_image, publish FROM sites WHERE publish = 'Y' ORDER BY site_name ASC LIMIT $start,144") or die(mysql_error());
?>
<table width="100%" border="0" cellspacing="4" cellpadding="4" align="center">
<tr>
<?
while($row = mysql_fetch_object($result))
{
echo '<td width="25%" align="center" valign="top"><a href= "',$row->site_address,'" target="_blank"><img src="samples/',$row->site_image,'"width="100" height="75" border="0"></a><br><a href= "',$row->site_address,'" target="_blank">',$row->site_name,'</a></td>'
if(++$i % 4 == 0)
echo '</tr><tr>'
}
?>
</table>

How Do I Display The Results Of A Test?
i just started learning php and have a quick question. this is my code:

$a=4;
$a==7;

what i want to know is how to display the results (either true or false). i tried print($a); but it only outputs the original variable value (in this case 4).

Display Results Vertically
I am creating a catalogue-like application and I want to display the items vertically instead of horizontally. Being somewhat new to PHP, the only thing I can think of are seperate queries for each field. Is there an easier way? Here's an example of how I want it to look.

Category 1
field1: result
field2: result
field3: result

Category 2
field4: result
field5: result

and so on and so forth....

Display The Number Of Results
How can I set the classical search engine message? Found ### results. How can I count the returned results and display them in the results page? so now has the Found 5 results or any number that the result contains.

Display Results According To Distance
I have a php/mysql driven website. On my search bar I have the option of searching by zip code. I have the function to find the radius of the surrounding zip codes. But I want to display the result along with my information from the other table.

An example would be:

I want to search for ads around my zip code for a range of 20 miles. The class I have will find all the zips and get their distances plus will sort them by closest to farthest. My problem is I want to display the records according to the distance provided. I heard of doing a sort with php but I am not sure which route to go.

I hope someone has found out how to do it, because this is the only thing left to do in order to launch the site.

How Do I Display Radio Button Results?
I have a form which uses several radio buttons to enter data. It works fine
as far as entering goes, but I can't figure out how to display which button
is checked when I view the record. I could do a if-then routine but it
seems like there should be an easier way.

Display Query Results In A Table
$sql = "SELECT name FROM employee_tb;
$result_query = @mysql_query ($sql);// run the query
while ($row = mysql_fetch_array($result_query,MYSQL_NUM)){
$name = $row[0];}
// assuming i have 8 results

how can i display the results from this query in a table with 3 rows each column?

Search & Display PEAR DB Results
I'm only a novice in PHP & PEAR DB, and currently stuck in an attempt to create a "search & display query PEAR DB results" page. Here's my pseudocode:

1) Display page with a searchbox and a search button.

2) Upon hitting the search button, run sql query ... Select all fields from TableA and selected fields from TableB where field1 like "searchbox" order by field1

3) If searchbox is blank
-> prompt user to enter search value
Elseif search result NOT found
-> alert user >> Record NOT found
Else
-> display results in a table (with alternating colours for each row)

4) Able to paginate the results in something like display 10, 20, 30, etc records on the same page .... the amount of records to be displayed can be manually selected by the user (via a dropdown box) ... with Previous Page, Next Page links as well.

>> How would I do that entirely in code from scratch? I've found other tutorials on doing it but it is tailored for MySQL ... but I'm using PEAR DB... the syntax is different.

>> Since I am querying two tables based on the same search value, how am i able to concatenate both the tables search results and display it inline in the display results page?

Display Search Results In Pages
im doing a query on a table that searches articles from the database, and i was wondering how i could display the results as groups of ten, so the next ten search matches are displayed when the user presses a page number.

3 Comlumn Display Results With Pagination
I have the following code that works perfectly.  I would like to add an easy pagination feature that limits the number of items, counts the number of records and makes links and pages for the next page. Code:

Display Number Of DB Results Beside A Link?
For an example, if you look at www.menupages.ie they give you a preview of how many results are found for each link.

ie:

 Ballsbridge Restaurants   (52)
 Blackrock Restaurants  (17)
 Clondalkin Restaurants  (18)
 Clontarf Restaurants  (17)

How is this achieved. I take it that it must be a select count on the DB for each row but that seems pointless, is there an easy way to achieve this?

Display Results Of Survey In A Table.
Is it possible to have them fill in a survey with about 10 form fields, then display
the results of everyone's survey in a table that can be sorted by different criteria
so new users to the site can instantly see which one of our services is better for them.

Display Results From Multiple Tables
I have two tables, one table (article_cat) has four fields ("id", "title", "feature1", and "feature2") and the other table has six fields (articles) has ("id", "cat_id", "title", "content", "feature1", and "feature2").

I am looking to display the "title" from the "article_cat" table that has "feature1" with a value of 1. And I want to display beneath that all the "title" results from the "articles" table where "feature1" has a value of 1. I have tried this a thousand ways with no luck. Code:

Limiting Results, And Display Page Numbers
How do I make it so only 50 items display per page. And if there's more than 50, it displays a link "page 2", "page 3" and so on? I know how to limit results with MySQL but how do I generate pages for the next 50 within the PHP code?

Select And Display Multiple Queries / Results
Howdy all, i've been looking through various sites / tutorials and through this php book I have here to try figure out whats causing this problem but haven't had any luck yet.

The problem is that its displaying the Designation as the link url instead of the jcode. Hope i explained this well. Above this bit of code has calls the individual Catagorys, if theres data in that catagory it will display it with whats below. PHP Code:

Display Results From Query In HTML-table
I'm working with PHP3 and Oracle 8. Can anyone tell me how to display the results from a query into my HTML-table?

Checkboxes In A Form To Determine Whether To Display In Results
I am making an effort to put checkboxes in my form that will determine whether to display that column or not. This is my first time doing this with PHP and I am hoping you gurus can assist. I have gotten some extremely great assistance in the past, so I am looking forward to any recommendations.

currently my form is as follows:

Display Results From A Database On Multiple Pages
I am new to PHP and Mysql but am really determined to learn these techniques. I have some script that reads and displays results from the databse onto a page. However, I really wish to limit the number of results that are displayed to 10 per page and then have the next/privious links under the results. With these results, the results under the email field should be hyperlinked so that the person viewing the results should double click on the email link and send the person an email. How can i do that? I have to learn this technique.

The code is:-

Getting Results To Display In Two Columns Of A HTML Table
How can i get the following script to display in two columns of a HTML table? At the moment i have it displaying in one column. If there are 5 results from the DB then the left HTML table column will display the 1st, 3rd and 5th result. The right HTML table column will display the 2nd and 4th results. Code:

Display Results From Text File In Multiple Pages
i use a string, eg "&&&" to mark pages in a text file. i use $count to count the above string. how can i display the contents of this file in multiple pages (by identifying the above string or any other method)?

Display Results From Text File In Multiple Pages
i use a string, eg "&&&" to mark pages in a text file. i use $count to count the above string. how can i display the contents of this file in multiple pages (by identifying the above string or any other method)?

Query Array, Sort Results And Display In Seperate Tables
The problem I have it breaking out the results and displaying them (broken out) alphabetically in seperate tables. For instance, I have generated (bookmarked) tables, one for each letter (A-Z) and want to display all recordsets with say, last name
beginning with "A" in one 2 column table, "B" in another 2 column table, and so on... each
table would have two columns (with 2 background colors alternating), each cell containing values of one recordset.

Even more tricky is if I have an odd number of cells, still generating the last cell with empty values (for asthetics). And can anyone say "sort" (yes, I am nuts)? The ability to sort the whole mess by any column value. I have looked at freeware and other third part apps, but they can only do what I already can do (mine is actually cleaner) but not as complicated.

Mysql_num_rows
On my local (win) comp i have apache+mysql+php 4.05
I'm counting rows using mysql_num_rows function, and everything works fine.
When i upload php file on server it says:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource in /home/optikara/public_html/crosun/izn/insert_form.php on line 80
Server runs php 5.0.5

Code is:
--------------------------
//connect to database code goes here
$result_v_smjestaj = mysql_query("select * from v_smjestaja order by
v_smjestaja_naziv ASC", $db);
// some other html code goes here

if (mysql_num_rows($result_v_smjestaj)) {
print "<select name="v_smjestaja">
";
while ($qry = mysql_fetch_array($result_v_smjestaj)) {
print "<option
value="$qry[id_smjestaja]">$qry[v_smjestaja_naziv]</option>";
}
print "</select>
";
}
--------------------------

Mysql_num_rows Vs. @mysql_num_rows
just want some clarification...what's the difference between these mysql functions? PHP Code:

Mysql_num_rows
I have a problem with mysql_num_rows returning an incorrect figure. Situation is a php script with a query as below:

$qstr = "SELECT * FROM A, B
$qstr .= "WHERE A.col1 = B.col2 AND B.F_AG_ID = $agent
$result = mysql_query($qstr);
$numrows = mysql_num_rows($result);
if ($debug) echo "$qstr <BR> Num - $numrows";

The query returns 3 rows when run directly against the database, but when run as part of the php script the $numrows is being displayed as 1. I've stopped/restarted mysql on the server, repaired all tables (none required) and am completely stumped.

Mysql_num_rows
I have a site that has multiple user postings on it. At the moment in time, they have one image name, username, pass and so on stored in the database. I wish to add a couple more images as a selection for the users to use. This works on an individual basis and i have rows setup in the table for each user.

Theres three tables img, img2 and img3. The basic principle is this. A user has to have a basic image, the name for that is defined in the field img. They can, if they wish, have two more images, img2 and img3. I tried to make some code up to check to see if img2 and img3 had the image name in them or not for the currently logged on user.

The idea is that, if the user has only the basic image name in the dbase, no drop down menu shows for him to select a picture. Otherwise if he has the img and img2 field in the database filled with data he has the option of 2 pictures. Likewise, if he has all three fields set he has the option of three images. PHP Code:

Mysql_num_rows()
I'm writing some classes in PHP, and now I want to store the affected rows from a SQL-query in a class-field. This is my code:

Mysql_num_rows Error
After a small PHP break and a whole lot of VB coding, I'm back with an issue that i know will be easy for most of you to resolve.

When ever i use mysql_num_rows() it returns the wrong number of rows. I have 10 rows in my table and it tells me that i have 9.

The way I have my Table set up is that there is an auto incremented index as a primary key. I know that it starts to auto increment at 1 and my guess is when i use mysql_num_rows() it starts at 0. Hence the difference in numbers.

Now the big question is, how do i get it to to display the accurate amount of rows/last index number inserted. I also tried mysql_affected_rows() but that just tells me the whole table was effected

Anyways,
any help in this matter would rock. I need to know the index number of the last record i inserted from my web site threw php.

Mysql_num_rows() Vs. COUNT()
Does anyone know what is more efficient to count row numbers with?
the mysql_num_rows() function on a query result or using the COUNT() function within a query. Anyone know?

Mysql_num_rows Always Returns Zero
My script finds my database, my table and nothing wrong with my select query but it always gives me the else statement echo. Code:

Mysql_num_rows() Error Msg
I'm trying to check to see if a username has already been taken before a new user can take it as their own username. PHP Code:

Problem With Mysql_num_rows()
I am getting the following error. I cant see what is wrong. I am probably
overlooking something obvious, can anyone see what is wrong ? The sql is ok
as used elsewhere. Problem only occurs when i include the mysql_num_rows()
function

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result...

Mysql_num_rows Error?
im getting the following error on the page below and its driving me crazy i cant make it work and dont know why!

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /files/home/wildtangent/arraytest.php on line 13 PHP Code:

Error Using Mysql_num_rows( )
Ive got the following code which works great on my localserver, but
when i upload it to my service provider i get an error

"Warning: mysql_num_rows(): supplied argument is not a valid MySQL
result resource in /opt2/home3/mitas/public_html/register.php on line
86

It seems to be only this function mysql_num_rows() causing a problem,
and the rest of the code works ok, and it adds data correctly.

I have checked with the provider, and they are using
PHP 4.3.10
mySQL 4.0.26

While im using
PHP 5.12
mySQL 5.0.15

Im wondering is this function supported by the older versions ?
Or any other ideas.

CODE------------------------------------------------------------
82 $conn=@mysql_connect( "myServer", "myUser", "myPassword" ) or die(
"Err:Conn" );
83 $rs = @mysql_select_db( "myDatabase", $conn) or die( "Err:Db" );

84 $sql="SELECT eMail FROM tblusers WHERE eMail="$eMail" ";
85 $rs=mysql_query($sql,$conn);
86 $mRecLen=mysql_num_rows($rs);
87 if ($mRecLen>=1) {
88 exit("Sorry,the record exists try another" );
89 }

END CODE----------------------------------------------------

Big Problems With Mysql_num_rows -
MySQL Server is version 4.1.7 (I know I should upgrade, and I will if
that is the problem but it has been working fine for 1.5 years now and
only recently has started to have this problem). Server is Linux
Redhat Enterprise 4. PHP is 4.4.4.

SQL STATEMENT:
==============
SELECT * FROM campaign_contact cc
LEFT JOIN optins_master co
ON cc.cc_cont_id=co.optin_id
WHERE cc.cc_camp_id=3270
AND (co.status_flag IS NULL OR co.status_flag!='unsub');

When I run the query, I get one of two results.

1. mysql_num_rows() returns the number of rows it found and all of the
data associated with it.

2. mysql_num_rows() returns 0 rows, but still gives me all of the
data. In the example above (cc.cc_camp_id=3270) it gives me 2,579
rows.

There doesn't appear to be any rhyme or reason as to whether or not it
returns the appropriate row count or not. The largest database in the
query is the campaign_contact database, but it only has approximately
15 million records in it. I am using UNSIGNED INT's for the record
id's, so I should have plenty of room to spare. On disk that database
takes up 439MB for the data and just over 1GB for the indexes.

I've shutdown the server and ran checks on everything to fix any index
problems (twice) and I still get the same problem.

Checking the packages I noticed this:

mysql-devel-4.1.7-4.RHEL4.1
mysql-server-4.1.7-4.RHEL4.1
mysql-4.1.7-4.RHEL4.1
mysqlclient10-3.23.58-4.RHEL4.1

^^^ mysqlclient v3.23.58?? I'm not sure if that could be causing the
problem, if it is I don't know why it has worked for 1.5 years now and
then all of the sudden we have issues.

I'm one of those people who don't believe in fixing something that
isn't broken. I'm happy to upgrade to 5.x if I know for sure it will
fix the problem, but I can't afford the time or money to upgrade if
I'll still be in the same boat.

*** UPDATE ***
I have upgraded everything to MySQL v5.0.27 (client/server/
development), and I recompiled PHP v4.4.4 and now it consistantly
returns 0 results (even though I still get all of my results if I were
to enumerate the $results returned from the mysql_query. Even
phpMyAdmin shows 0 results returns, but then below that it displays
all of the matching rows.

Mysql_num_rows Issues
$item_name = $_POST['item_name'];
$item_author_id = $_SESSION['id'];
$item_location = $_POST['item_location'];
$item_description = $_POST['item_description'];
$item_type = $_POST['item_types'];
$extra_notes = $_POST['item_notes'];
$check_name = mysql_query("SELECT * WHERE item_name = '{$item_name}'");

if (mysql_num_rows($check_name) == 0){...

error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:WAMPwwwPPitemprogramcreate_item.php on line 14

trying to make it so it will check if that item name has already been used ot not, if not it will do the if and if no it will do the else.

PDO Version Of Mysql_num_rows(); ?
I need the PDO equivalent of mysql_num_rows. I thought this would work but it doesn't:

$numrows = $pdo->query("SELECT * FROM tipsntricks")->fetchAll();
echo "There were " . count($numrows) . " rows in the table";

Mysql_num_rows .... Error??? Any Ideas?
Does anyone have a good reason why I'm getting this error.
I'm clueless on this one...

I'm getting the error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource.

So, SELECT Count(*)... Or Mysql_num_rows(...)
I was running a test on a table with 50000 rows.
When I do:

$sql = "SELECT * FROM TABLE";
$result = mysql_query($sql);
$total = mysql_num_rows(result);

I get a 'run out of memory error', (the limit is set low on the test
server).

But when I do:

$sql = "SELECT count(*) as num FROM TABLE";
$result = mysql_query($sql);
$result = mysql_fetch_assoc( $result );
$total = $result['num'];

Everything works fine.

or is
$sql = "SELECT FOUND_ROWS() AS num FROM TABLE";
...
even better?

So What is the 'preferred' method of getting a row count?

Foreach+Count Sum From Mysql_num_rows
do you know how to sum the data from mysql_num_rows. PHP Code:

Mysql_num_rows() Fuction Error
I'm using a book called "PHP and MYSQL WebDevelopment" I took the code for a web forum and tried to run it on an Apache server on a W2K machine when I got this error

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in htdocsookforumdiscussion_fns.php on line 9 PHP Code:

Imagedestroy And Similar
is there a difference between imagedestroy($ih) and unset($ih)?

The same with other similar functions like closedir, mysql_close,
curl_close, mysql_free_result, etc.

And by the way... will the garbage collector even detect an "implicit
unset" when a resource is used for the last time?

Similar Pages ...
I have about twenty pages now, all with various scripts. All of them are different but the header and the footer are always similar

eg.

.....<HTML>...<HEAD>..<BODY>.....<TD>

{content}

</TD>end of file stuff</html>

Should I put the front and the end in a special function so that I can change all of them at once?

Get Similar? - Mysql
Is it possible to get similar results in mysql? For example if i searched for papa_face and there was a record in the db named papa_flag is it possible to pull that result aswell automatically?

ImageMerge Or Similar
Again with my chatbox, I am trying to impliment 'smilies' into it, which is proving a challenge. 

My plan is that if the user types, for example, '=(' it will replace it with a sad emoticon.

I am imagining that I will need to merge (or similar function) the smilie image onto the chatbox image.

How would I go about doing this? also how would I get it to put the emoticon at the location of the word that it will replace?

Something Similar To Cron On A Windows Box?
Is there something similar to cron where i can run a script at a certain time on certain days but on a windows box. If not something on windows, could i write a PHP script that will run at these times. The purpose of this is to create backups for a MySQL DB.

Can Php Do Somthing Similar To Webclient() In Asp.net?
I would prefer to stick with PHP, but am wondering if it can do the same thing that webclient() does in asp.net.

Basically, it retrieves a page of a particular URL that you provide. It returns it in html for. Keep in mind that this is different from xml. I want to scrape the screen of any url, not just retrieve what has been setup via xml. Am example is shown here (asp.net)

http://aspnet.4guysfromrolla.com/de...ScrapeDemo.aspx


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