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 9106813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:25:35+00:00 2026-06-17T02:25:35+00:00

I have a problem when I try to extract from table (modele) all data

  • 0

I have a problem when I try to extract from table (modele) all data from ‘marca’ (marca contains nokia, samsung, etc)

so I try to use $_GET but is is not working. I can select a line from table just with $_GET id but this does not help me, because I want to make categories selectable from links so sql inject like localhost/article.php?marca=nokia (must appear just nokia phones) I think is the best way.

For now I am using code wich shows me last 5 posts sorted by id but it is not working correctly because it show nokia, samsung, htc, nokia, other, nokia.

<?php require 'SQL.php';

$id = isset($_GET['id'])?(int)$_GET['id']:0; // daca $_GET['id'] exista, folosestel ca      integer, altfel trucul sentinel, de obicei id incepe cu 1, deci 0 va functiona

if ($id!=0): 
// Vom procesa daca exista doar 1 inregisrare in baza de date
$query = 'SELECT marca FROM modele WHERE id='. $id .' LIMIT 1'; // voi folosi 1,    nemaiavand nevoie de alti pasi pentru lookup in sql
else:$query = 'SELECT marca FROM modele ORDER BY id DESC LIMIT 5'; 
endif;

$result = mysql_query($query);
// now loop through the results
while($linie = mysql_fetch_array($result))
{
    // le voi utiliza dupa bunul plac
    echo ''.$linie["marca"].'<br />';
} 
?>

to work properly it must show me only nokia, nokia, nokia what’s missing?

If is another way, please let me know!

  • 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-17T02:25:36+00:00Added an answer on June 17, 2026 at 2:25 am

    No, using the following query:

       SELECT marca FROM modele ORDER BY id DESC LIMIT 5
    

    you are displaying all marca from modele you should add where clause, e.g.

       SELECT marca FROM modele 
       where marca = 'nokia'
       ORDER BY id DESC LIMIT 5
    

    You can retrieve the marca name from GET using $_GET["marca"].
    http://www.w3schools.com/php/php_get.asp

    Read also about sql injection, cause I fell that you will get there.

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

Sidebar

Related Questions

I have a problem when try to use hashtable with large data. I have
i am having this problem try to use the cocos2d CCScrollLayer I have added
I use Matlab's Database Toolbox to extract data from a SQL Server database. Today
I need to extract data from files in directory /tmp/log . I have no
I have small problem. I try to write a function to extract something in
i have a problem in inserting some data into a table. I have done
I have data from a table in a database (string) that contain text and
i have a problem when try to get and parse a remote JSON. require
I have a problem when I try to count how many times a word
I have a problem when I try to persist my model. An exception is

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.