GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 04-Jun-2004, 16:18
spiritvw spiritvw is offline
New Member
 
Join Date: Jun 2004
Posts: 2
spiritvw is on a distinguished road

newbie needs help


I am using php to dynamically list a series of links along with a short description of the article which the link opens in a new wondow. I have a SQL database which I am working with through phpMyAdmin and everything is working great...
- EXCEPT: I have a php code that limits the amount of links shown on the page at a time. When you enter the page where the links are, only 3 of them should appear at a time. If there are more than that in the database a "Next Page... " link appears which will merely replace the current 3 links with the next 3, and so on. It all works well at first - ie. only 3 links appear, they are in the correct order and they link correctly. BUT when I click on "Next Page... " - the 3 current links are replaced with only one link which is actually the very first link in the table. Instead it should be the next 3 links...

PLEASE HELP!
Here is the code:
PHP Code:

if ($pageA == "") {
$counterA = 0;
$pageA=1;
}
else if ($pageA >= 1) {
$counterA = ($pageA*3);
}

$maxA = ($pageA*3);
$minA = (($pageA-1)*3);

if ($category == "Genre") {
$resultA = mysql_query("SELECT `Name` FROM `articles` WHERE `$category` = \"yes\" ORDER BY ID ASC LIMIT 0, 30", $link_id);
$resultB = mysql_query("SELECT `Description` FROM `articles` WHERE `$category` = \"yes\" ORDER BY ID ASC LIMIT 0, 30", $link_id);
$resultC = mysql_query("SELECT `Article` FROM `articles` WHERE `$category` = \"yes\" ORDER BY ID ASC LIMIT 0, 30", $link_id);
$query_dataB = mysql_fetch_row($resultB); 
$query_dataC = mysql_fetch_row($resultC);
while($query_dataA = mysql_fetch_row($resultA) AND $counterA <= $maxA AND $counterA >= $minA) {
$counterA++;
echo "<p class=\"spaced\"><b><a class=\"spaced\" href=\"article.php?subcat=$query_dataA[0]&subcatC=$query_dataC[0]\" target=\"_blank\">$query_dataA[0]</a></b><br>$query_dataB[0]</p>";
if ($counterA == ($pageA*3))  {
$counterA++;
$pageA++;
$countisA = ($counterA-1);

echo "<p><a href=\"$PHP_SELF?category=$category&pageA=$pageA&counterA=$countisA&client=$client\">Next Page...</a></p>";
}
}
} 


Last edited by JdS : 05-Jun-2004 at 09:42. Reason: Please enclose PHP code in [php] & [/php] for syntax highlighting
  #2  
Old 09-Jun-2004, 21:50
JUNK KED JUNK KED is offline
Awaiting Email Confirmation
 
Join Date: Oct 2003
Location: uk&ireland
Posts: 85
JUNK KED will become famous soon enough

please explain your scipt


If you want more help with your script you will have to clarify each stage.
I am not very experienced in PHP and MSQL but if you answer my questions maybe somebody will see your problem. please fill in your answers inside the comment markers.
PHP Code:

if ($pageA == "")             
$counterA = 0;
$pageA=1;
}                           
else if ($pageA >= 1) {
$counterA = ($pageA*3);
}                                   

$maxA = ($pageA*3);
$minA = (($pageA-1)*3);   /* What are these counters counting*/

if ($category == "Genre") {
$resultA = mysql_query("SELECT `Name` FROM `articles` WHERE `$category` = \"yes\" ORDER BY ID ASC LIMIT 0, 30", $link_id);
$resultB = mysql_query("SELECT `Description` FROM `articles` WHERE `$category` = \"yes\" ORDER BY ID ASC LIMIT 0, 30", $link_id);
$resultC = mysql_query("SELECT `Article` FROM `articles` WHERE `$category` = \"yes\" ORDER BY ID ASC LIMIT 0, 30", $link_id);
/* What is this IF checking */
$query_dataB = mysql_fetch_row($resultB); 
$query_dataC = mysql_fetch_row($resultC);

while($query_dataA = mysql_fetch_row($resultA) AND $counterA <= $maxA AND $counterA >= $minA) {
$counterA++;

/* What does this WHILE do*/

echo "<p class=\"spaced\"><b><a class=\"spaced\" href=\"article.php?subcat=$query_dataA[0]&subcatC=$query_dataC[0]\" target=\"_blank\">$query_dataA[0]</a></b><br>$query_dataB[0]</p>";

if ($counterA == ($pageA*3))  {
$counterA++;
$pageA++;
$countisA = ($counterA-1);

/* what does this IF do */

echo "<p><a href=\"$PHP_SELF?category=$category&pageA=$pageA&counterA=$countisA&client=$client\">Next Page...</a></p>";
}
}
} 


[/quote]




Maybe you should rewrite it if nobody can figure out your problems.
Here are some suggestions.

Your script is confusing. You are doing PHP and MSQL operations the same time separate them.

Create another table with data in correct format.
Fill an array with all data.
Then manipulate the arrary.


This will be easier to use and has ONE call to MYSQL.

Hope you get a fix

JK
Last edited by JUNK KED : 09-Jun-2004 at 21:59. Reason: adding text
  #3  
Old 10-Jun-2004, 14:36
spiritvw spiritvw is offline
New Member
 
Join Date: Jun 2004
Posts: 2
spiritvw is on a distinguished road

figured it out - thanks


figured it out - thanks
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
linked lists, newbie needs help moltarim C Programming Language 4 06-May-2004 12:32
newbie using Sam's series Skampy C++ Forum 3 06-Mar-2004 19:51
Grouping data from MySQL with PHP - Newbie question. giobbi MySQL / PHP Forum 12 27-Feb-2004 01:34
(read/write file) newbie need help plz momotx C Programming Language 6 28-Jan-2004 14:40
[Linux] Top newbie questions. JdS Computer Software Forum - Linux 3 22-Jan-2004 13:00

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:03.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.