Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

displaying cats

Featured Replies

Hi i have a script that i suposed to get a list of the items in my database with a cat id of 25 but it doesnt work....

here is the script

 

 

<?php

//connect to database

$mysqli = mysqli_connect("host", "user", "pass", "db");

 

 

if (isset($_GET["cat_id"])) {

//get items

$get_items_sql = "SELECT id, item_title, item_price FROM store_items WHERE cat_id = '".$cat_id."' ORDER BY item_title";

$get_items_res = mysqli_query($mysqli, $get_items_sql) or die(mysqli_error($mysqli));

 

if (mysqli_num_rows($get_items_res) < 1) {

$display_cat = "<p><em> Sorry,There are no items in this category.</em></p>";

} else {

$display_cat .= "<ul>";

while ($items = mysqli_fetch_array($get_items_res)) {

$item_id = $items['id'];

$item_title = stripslashes($items['item_title']);

$item_price = $items['item_price'];

 

$display_cat .= "<li><a href=\"showitem.php? item_id=".$item_id."\">".$item_title."</a>(\$".$item_price.")</li>";

}

$display_cat .= "</ul>";

}

}

 

mysqli_close($mysqli);

 

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>

<body>

 

<?php echo $display_cat;

 

?>

</body>

</html>

 

Any help would be greatly apreciated

You haven't set the $cat_id variable when you use it in the first query...

 

$cat_id = $_GET['cat_id'];

Assuming you've said your database details correctly...

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.