Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8189061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:09:04+00:00 2026-06-07T03:09:04+00:00

I’m here again, with a problem. This is my code: $sql = SELECT *

  • 0

I’m here again, with a problem. This is my code:

$sql = "SELECT * FROM paginas WHERE subpagina='0'"; 
$q = $con->prepare($sql);
$q->execute();
$q->setFetchMode(PDO::FETCH_ASSOC);
$row = $q->fetch();

if (count($row) != "0")
{
    echo '<ul>';
    while($row = $q->fetch())
    {
       echo '<li><a href="?page='. $row['ID'] . '">' . $row['pagina'] .'</a></li>';
    }
    echo '</ul>';   
}

The problem is, all the records in the database where subpagina = 0 will be echoed on the page. But, if I use another string like 3 in the database, and in this code, it doesn’t work.

I have done some thing like var_dump $row, var_dump(erroinfo()), but it only returns FALSE.

I hope you can help me.

EDIT: here is my data structure:

CREATE TABLE IF NOT EXISTS `paginas` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `pagina_link` varchar(150) NOT NULL,
  `content` varchar(10000) NOT NULL,
  `pagina` varchar(100) NOT NULL,
  `reactie` varchar(1) NOT NULL,
  `subpagina` varchar(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=39 ;

EDIT2: here is the data

INSERT INTO `paginas` (`ID`, `pagina_link`, `content`, `pagina`, `reactie`, `subpagina`) VALUES
(32, '?pagina=Home', '<h1>Welkom!</h1><div>Dit is een demo van het cms combora! Je mag hier op uittesten. Je kan inloggen met als gebruikersnaam demo en paswoord demo. Gelieve deze pagina niet te verwijderen.</div><div><br></div> <a href="?pagina=Home&foto=2&l=j"><img width="250px" height="250px;" src="fotos/foto2.jpg"></a>', 'Home', '1', '0'),
(33, '?pagina=test1', '<br>dslmlmqdhfkqsjdf', 'test1', '1', '0'),
(34, '?pagina=test2', '<br>', 'test2', '0', '0'),
(35, '?pagina=Nice', 'fasdfdsfadsf<br>', 'Nice', '1', '0'),
(36, '?pagina=Foto viewer ', 'Deze pagina is een test van de zelfgemaakt foto viewer:<div><br></div>\r\n<a href=\\"?foto=1&amp;l=j\\"><img width=\\"250px\\" height=\\"250px;\\" src=\\"1.jpg\\"></a>\r\n<a href=\\"?foto=2&amp;l=j\\"><img width=\\"250px\\" height=\\"250px;\\" src=\\"2.jpg\\"></a>\r\n<a href=\\"?foto=3&amp;l=j\\"><img width=\\"250px\\" height=\\"250px;\\" src=\\"3.jpg\\"></a><div><br></div>', 'Foto viewer ', '1', '0'),
(38, 'sdkjfqsdfj', 'sdjmkqjfdmlkqsfdlmkqjsdflkjdlmskfjqslmdkfj', 'test56', '1', '2\r\n');

I’m not sure if you mention this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:09:04+00:00Added an answer on June 7, 2026 at 3:09 am

    You mentioned it is a string. Try

    $sql = "SELECT * FROM paginas WHERE subpagina='0'"; 
    

    Fiddled a limited set of your table. Added some data and the above SELECT simply works. So that’s not the problem. Are you sure you have other strings than '0' in the subpagina field?

    See this sqlfiddle

    Another thing you can try is

    There’s no such thing as subagine = 3 in your data. Only 0 and 2 exist

    $row = $q->fetchAll(); 
    print_r($row);
    /* print_r shows Array only */
    /* loop the array and print the values */
    foreach($row as $key => $value)
    {
       echo $key + " " + $value + "\r\n";
    }
    

    EDIT

    See it only just now: you do a fetch() assing it to $row and check the count. Then you start the while loop wiht anohter fetch() which will get the NEXT row of the result. The first one is skipped always because of the first fetch()

    use something like this:

    $rows = $q->fetchAll(); 
    
    echo '<ul>';
    foreach($rows as $value)
    {
       echo '<li><a href="?page='. $value['ID'] . '">' . $value['pagina'] .'</a></li>';
    }
    echo '</ul>'; 
    

    if you not want the empty <ul> tags you should check if count($rows) > 0 before you echo/foreach/echo

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.