Hello everyone,
i am building a bookmarking system for my website, so that users can bookmark pages.
i have all of my php code setup for this sytem, now i need to add the database code.
i have played with code and it is working but i can't figure out a way to organize the data coming out of the database.
$results holds an array of all of the db data. I want this data to be placed into arrays corresponding to icon types.
i have two icon types: circles (border-radius: 50%;) and squares/rectangles.
*i know the diff between a sq and a rectangle but the word squares is a smaller variable name than rectangles, so i call them squares.
i have tried several ways to separate the types into arrays but i am unable to load each row into its own array.
bookmarks columns in database: type, name, icon, link.
i'd like to have a new array named $circles which should hold the row data:
$circles = ['','','',''];
i guess that my real problem is not understanding how to build this array.
while ($results = $sth->fetch()) {
switch ($results['type']) {
case 'circle':
$circles[$results['icon']] = $results['link'];
break;
case 'square':
$squares[$results['icon']] = $results['link'];
break;
}
}
i just added $circles[$results['icon']] = $results['link']; today because i don't know how to construct this array.
the entire row should be in $circles. so i guess $circles[0] should hole an array which holds the row values?
what i am trying to do is display the bookmarks by type on the page.
circles require different css than squares (maybe better described as rectangles).
so on my html page, i want all circle icon bookmarks displayed in one div
and all square/rectangle icon bookmarks displayed in a separate div.
i all ready have the bookmark data set up.
i just need the database created, then i need to extract this data.
i've practiced and it is working but i need the data to be categorized when it comes out of the database.
i am a novice with this code. I don't know how to loop through the code to separate it.
anyone able to offer tips of how to accomplish this task?
Best wishes,
John
[edited by: phranque at 7:30 am (utc) on Aug 20, 2020]
[edit reason] disable graphic smile faces [/edit]