WmZilla - Webmaster and Marketplace

The Next Generation Webmaster and Trade Forum

Retrieving data from two separate tables

kyllua

New member

0

0%

Status

Offline

Posts

49

Likes

0

Rep

0

Bits

255

3

Months of Service

0%
In the database, we have two tables named 1-categories and videos.
The structure of the 'categories' table:
CREATE TABLE IF NOT EXISTS `categories` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`category` varchar(255) DEFAULT NULL,
`image` varchar(255) DEFAULT NULL,
`menu` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=0;
The structure of the 'videos' table:
CREATE TABLE IF NOT EXISTS `videos` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_turkish_ci NOT NULL,
`video_link` text COLLATE utf8_turkish_ci NOT NULL,
`menu` varchar(255) COLLATE utf8_turkish_ci DEFAULT NULL,
`views` int(11) NOT NULL,
`x` varchar(255) COLLATE utf8_turkish_ci NOT NULL,
`category` varchar(50) COLLATE utf8_turkish_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_turkish_ci AUTO_INCREMENT=0;
In the 'categories' table, I assign an image based on the category name. For example, when the category is "Arka Sokaklar," I attach a consistent poster image.
However, my request is to have the system bring the category image when adding a new video. Here is the code on the homepage that needs editing:
$sql = mysql_query("select * from videos order by id DESC");
while ($result = mysql_fetch_array($sql)) {
This code needs modification.
 

249

6,622

6,642

Top