View Full Version : related video recordset question

11-26-2008, 11:45 PM
I hope I explain this well enough but I want to know if anyone can help me this.

I have 2 tables in my database, 1 called artists with a url to the main video and another called related videos that have urls to related videos to the main video.

I have got to the point where I have video1.php with the related video2 also on the page and you can click on video2 and that goes to video2.php. But my problem is that when I click on video2.php I want video1 to be the related video.

I have done all this through dreamweaver server behaviors but can't get this to work. Any help would be fantastic.

11-27-2008, 09:46 AM
well done for getting this far with the behaviours

i think ed is (drinking from the poisonous chalis) helping with these issues i mean.

He will be along to help soon

11-28-2008, 12:16 AM
goodbye cruel world. post your code

11-28-2008, 12:59 PM
<?php require_once('Connections/artists.php'); ?>
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
return $theValue;

mysql_select_db($database_artists, $artists);
$query_artist_videos = "SELECT * FROM artists";
$artist_videos = mysql_query($query_artist_videos, $artists) or die(mysql_error());
$row_artist_videos = mysql_fetch_assoc($artist_videos);
$totalRows_artist_videos = mysql_num_rows($artist_videos);

mysql_select_db($database_artists, $artists);
$query_letters = "SELECT * FROM letters";
$letters = mysql_query($query_letters, $artists) or die(mysql_error());
$row_letters = mysql_fetch_assoc($letters);
$totalRows_letters = mysql_num_rows($letters);

mysql_select_db($database_artists, $artists);
$query_subjects = "SELECT * FROM subjects";
$subjects = mysql_query($query_subjects, $artists) or die(mysql_error());
$row_subjects = mysql_fetch_assoc($subjects);
$totalRows_subjects = mysql_num_rows($subjects);

$colname_artist_video = "-1";
if (isset($_GET['artist_id'])) {
$colname_artist_video = $_GET['artist_id'];
mysql_select_db($database_artists, $artists);
$query_artist_video = sprintf("SELECT * FROM artists WHERE artist_id = %s", GetSQLValueString($colname_artist_video, "int"));
$artist_video = mysql_query($query_artist_video, $artists) or die(mysql_error());
$row_artist_video = mysql_fetch_assoc($artist_video);
$totalRows_artist_video = mysql_num_rows($artist_video);

$colname_related_info = "-1";
if (isset($_GET['related_video_id'])) {
$colname_related_info = $_GET['related_video_id'];
mysql_select_db($database_artists, $artists);
$query_related_info = sprintf("SELECT * FROM related_videos WHERE related_video_id = %s", GetSQLValueString($colname_related_info, "int"));
$related_info = mysql_query($query_related_info, $artists) or die(mysql_error());
$row_related_info = mysql_fetch_assoc($related_info);
$totalRows_related_info = mysql_num_rows($related_info);

$colname_related_videos = "-1";
if (isset($_GET['related_video_id'])) {
$colname_related_videos = $_GET['related_video_id'];
mysql_select_db($database_artists, $artists);
$query_related_videos = sprintf("SELECT * FROM related_videos WHERE artist_id = %s", GetSQLValueString($colname_related_videos, "int"));
$related_videos = mysql_query($query_related_videos, $artists) or die(mysql_error());
$row_related_videos = mysql_fetch_assoc($related_videos);
$totalRows_related_videos = mysql_num_rows($related_videos);

11-29-2008, 01:27 AM
difficult to say from this , lot of select statements there.
let me try to understand.
first you would select an artist video.
that would display on another page and have all other vids by that artist.
it sounds like the prob is on the second page . do you have this live? i cant see any php code but might help me understand the prob better.

11-29-2008, 03:32 PM
here is the site http://100pixels.co.uk/sound/index.php

12-01-2008, 12:54 AM
you use Artist-id to pass the value first , you will need to pass this on in the link of the related video also
?related_video_id = & artist_id= you can then use the dw record set.

12-01-2008, 03:54 PM
thankyou, this is getting closer to what I want but there are still a few little problems.

When you click on the slipknot videos it shows to 2 related videos which you can click and go to that page, this is good so far.

Once you have clicked on a related video is now shows the first video in the related videos column, this is what I wanted so again good so far. But it only shows the first video and not the other related video, I'm sure this can be done.

Another problem is that when I click on the killers 'human' link it goes to that page and shows the related video, good so far but when I click on that related video it goes to the right page but it's the slipknot video that is shown in the related videos box.

take a look to get a better idea of were I'm at now. http://www.100pixels.co.uk/sound/index.php

12-02-2008, 12:42 AM
the link reads
http://100pixels.co.uk/sound/smile_like_you_mean_it.php?related_video_id & artist_id=2
it should be ( i guess)
http://100pixels.co.uk/sound/smile_like_you_mean_it.php?related_video_id=(here it needs a record no) & artist_id=2

this will have to be got dynamically from your database

12-02-2008, 03:05 PM
ok I have done that but I thought it would have been something to do with my recordset on the 'smile_like_you_mean_it.php' page?

12-03-2008, 12:49 AM
link still reads http://100pixels.co.uk/sound/smile_like_you_mean_it.php?related_video_id & artist_id=2
lets go back a minute
if the artist id is the same in both tales you will only need to pass a value of the artists id , lets say slipnot is 1. You have got this dynamically from a record set so your link will be ie
<a href ="yourpage.php?atistid=<? php recordset['artist_id'];?>

pass ing then a value of your_page.php?artistid=1
on a page where you want to use this you will get that value as $_GET{'artistid']:

so if you base your record set on this value and echo this in a do while loop or in DW wizard speak repeating region, you will echo all links in that table .