close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

I'm at a loss...lol

Thread began 3/21/2010 10:50 am by akstudio | Last modified 3/24/2010 1:07 pm by akstudio | 2259 views | 5 replies

akstudio

well basically, the page is a "video library" - a page which returns all records from the db.

On this page I am pulling records from 3 tables:

//**************

SELECT
videos.product,
videos.product_id,
videos.small_thumbnail,
videos.title,
videos.description,
videos.video_length,
videos.channel_id,
videos.ID as linkid,
tags.ID,
tags.name,
products.product,
products.ID
FROM
videos
INNER JOIN tags ON (videos.channel_id = tags.ID)
INNER JOIN products ON (videos.product_id = products.ID)

//**************

I am displaying the video information, associated channel and product.

Obviously, this page needs pagination.

On top of all that, I need 2 drop-downs. One for channels, and one for products. These drop-downs will allow a user to sort by either channel, OR product, and thus, return the results based on that input. These drop-downs connect to the appropriate table for their data.

Somehow, after many hours or work, I managed to get this almost working. The problem I current have is the drop-downs. In my Select I am doing this:

//*****

if(isset($_REQUEST['channel_sort']) or isset($_REQUEST['product_sort']) or isset($_REQUEST['solution'])){
$newchannel = $_REQUEST['channel_sort'];
$newproduct = $_REQUEST['product_sort'];
//$newsol = $_POST['solution'];*/

$query_video_library = "SELECT
videos.product,
videos.product_id,
videos.small_thumbnail,
videos.title,
videos.description,
videos.video_length,
videos.channel_id,
videos.ID as linkid,
tags.ID,
tags.name,
products.product,
products.ID
FROM
videos
INNER JOIN tags ON (videos.channel_id = tags.ID)
INNER JOIN products ON (videos.product_id = products.ID)
WHERE
videos.channel_id = '$newchannel' OR videos.product_id = '$newproduct'";


} else {


$query_video_library = "SELECT
videos.product,
videos.product_id,
videos.small_thumbnail,
videos.title,
videos.description,
videos.video_length,
videos.channel_id,
videos.ID as linkid,
tags.ID,
tags.name,
products.product,
products.ID
FROM
videos
INNER JOIN tags ON (videos.channel_id = tags.ID)
INNER JOIN products ON (videos.product_id = products.ID)";
}

//*****

The OR is messing me up. If i use AND, it works as intended, however, forces a user to choose from both drop-downs.

I had to do some custom hacks with the drop downs in order for them to work with pagination (tom-muck's list) - by default, the drop downs would reset and show the first channel, every time you used the pagination links. It was passing the current value, along with the chosen one, and returning all kinds of oddities.

Here is the pagination with dropdowns:

//*****


<?php
$channel = '';
if (isset($_REQUEST['channel_sort']) && !empty($_REQUEST['channel_sort'])) {
$channel = 'channel_sort='.$_REQUEST['channel_sort'];
}

for ($i=0; $i <= $totalPages_video_library; $i++) {
$TFM_counter = ($i) * $maxRows_video_library + 1;
$TFM_endCounter = min($totalRows_video_library,$TFM_counter + $maxRows_video_library - 1);
if($i != $pageNum_video_library) {
//printf('<a href="'."%s?pageNum_video_library=%d%s", $currentPage, $i, $queryString_video_library. $channel .'">');
echo '<a href="'.$currentPage.'?pageNum_video_library='.$i.$queryString_video_library.'&'.$channel.'">';

echo "$TFM_counter-$TFM_endCounter</a>";
}else{
echo "<strong>$TFM_counter-$TFM_endCounter</strong>";
}
if($i != $totalPages_video_library) echo " | ";
}
?>


<form id="form1" name="form1" method="post" action="<?php echo $currentPage;?>">
<label>
<select name="channel_sort" class="input_styles_sm" id="channel_sort">
<option value="channel">Channel</option> <?php


do {
?>
<option value="<?php echo $row_sort_channel['ID'];
if (isset($_REQUEST['channel_sort']) && $_REQUEST['channel_sort'] == $row_sort_channel['ID']) {
echo 'selected="selected"';
}
?>"><?php echo $row_sort_channel['name']?></option>
<?php
} while ($row_sort_channel = mysql_fetch_assoc($sort_channel));
$rows = mysql_num_rows($sort_channel);
if($rows > 0) {
mysql_data_seek($sort_channel, 0);
$row_sort_channel = mysql_fetch_assoc($sort_channel);
}
?>
</select>
</label>

<!-- second dropdown -->

<select name="product_sort" class="input_styles_sm" id="product_sort">
<option value="channel">Product</option> <?php


do {
?>
<option value="<?php echo $row_sort_product['ID'];
if (isset($_REQUEST['product_sort']) && $_REQUEST['product_sort'] == $row_sort_product['ID']) {
echo 'selected="selected"';
}
?>"><?php echo $row_sort_product['product']?></option>
<?php
} while ($row_sort_product = mysql_fetch_assoc($sort_product));
$rows = mysql_num_rows($sort_product);
if($rows > 0) {
mysql_data_seek($sort_product, 0);
$row_sort_product = mysql_fetch_assoc($sort_product);
}
?>
</select>


<input name="" type="submit" value="Submit" />
</form>

//*****

So anyway, at this point, I have it almost working, except for the OR in the select.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...