Forum Moderators: open
Table applications
id int(11)
location int(11)
name varchar(255)
version varchar(255)
icon varchar(255)
file varchar(255)
time int(11)
utime int(11)
category varchar(255)
plat int(1)
sos varchar(255)
os varchar(255)
architecture varchar(255)
requirements mediumtext(0)
sdescription varchar(255)
description mediumtext(0)
keywords varchar(255)
history mediumtext(0)
downloads int(11)
vdownloads int(11)
apppath varchar(255)Table posts
id int(11)
data mediumtext(0)
forum int(11)
thread int(11)
username varchar(255)
useremail varchar(255)
time int(11)
Table reviews
id int(11)
app int(11)
data mediumtext(0)
username varchar(255)
useremail varchar(255)
time int(11)
and here is the code I got now for retrieving how many there is in each.
$app_query = "SELECT * FROM applications WHERE";
$posts_query = "SELECT * FROM posts WHERE";
$reviews_query = "SELECT * FROM reviews WHERE";
$i=0;
foreach ($qs as $qed) {
if ($i!=0)
$app_query .= " OR";
$app_query .= " name LIKE '%$qed%' OR description LIKE '%$qed%' OR category LIKE '%$qed%' OR keywords LIKE '%$qed%' AND hidden=0";
if ($i!=0)
$posts_query .= " OR";
$posts_query .= " username LIKE '%$qed%' OR data LIKE '%$qed%'";
if ($i!=0)
$reviews_query .= " OR";
$reviews_query .= " username LIKE '%$qed%' OR data LIKE '%$qed%'";
$i++;
}
$result = mysql_query($app_query);
$numapps = mysql_num_rows($result);
mysql_free_result($result);
$result = mysql_query($posts_query);
$numposts = mysql_num_rows($result);
mysql_free_result($result);
$result = mysql_query($reviews_query);
$numreviewss = mysql_num_rows($result);
mysql_free_result($result);
Thanks for any help,
Mr. Gecko
Putting found elements in an array is a solution, but one that will use up an unnecessary amount of memory. Additionally it will have to read in the whole table of results, and if it's quite large, will slow you down.
Something like this: you have a "get_foot_links" routine that counts the total results. You parse through the count and output links based on how many you want per page (logic only, not working code:)
$per_page=10;
for ($i=1;$i<=$total_records;$i+=$per_page) {
$end = $i+$per_page;
$foot_links .= "<a href=\"yourscript?start=$i&per=$per_page\">$i\-$end</a> ¦ ";
}
(Simplified, you have to do something special for the last link if it's not equally divisible by $per_page.)
Then you use the start and per variables in your query string to build the limit clause in your select:
$select = "select * from $table";
if ($per_page > 0) {
$start=($start>0)?$start:0;
$select .= " limit $start,$per";
}
Which should give you
select * from $table where [conditions] limit 20, 10;
which would start on the 20th record found, grab the next 10, and stop querying at that point.