0

sorry i a begginer of php. I have url example here: http://example.com?category=software-hardware .Actual of category is Software & Hardware I using this script to get url above

foreach ( $key as $value ) {
    $c = array(' ', '&-');
    $d = array('-', '');
    echo "<a href=\"category/".strtolower(str_replace($c, $d, $value->kategori_laporan))."\" class=\"list-group-item\">".$value->kategori_laporan."</a>";   
}

How To get data from my condition url.? Sorry, i bad using english. I want to create url like category from slideshare. Please help me.! Thanks.!

7
  • From what I understand, you want to change software-hardward to Software & Hardware. Is that right? Commented Jul 12, 2016 at 12:53
  • 1
    Is this what you're looking for $category = $_GET["category"] . Also check out this link to see if it helps clear things up php.net/manual/en/reserved.variables.get.php Commented Jul 12, 2016 at 12:55
  • This looks like an XY Problem. Tell us what exactly you want? Commented Jul 12, 2016 at 12:56
  • $value->kategori_laporan <- that part is strange too! Why is $value an Object with the property kategori_laporan ? Reedit / Repost your question :) Commented Jul 12, 2016 at 13:02
  • exactly i want to create like url category from slideshare.net. my url example.com/category/software-hardware. Data of this category not show, because category in my database is Software & Hardware. :D Commented Jul 12, 2016 at 13:14

2 Answers 2

1

you can fetch it like:

$cat = $_GET['category'];

and you don't need any foreach

Sign up to request clarification or add additional context in comments.

1 Comment

I use foreach to show all data category from my database.
0

$_GET is an associative array having all the query string keys values.

You can get value of any query string parameter from this array by passing the key of query string parameter.

To get category you can use $_GET["category"] in your case.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.