Hey everyone, first post, but I've browsed here enough to know I'm in the right place (of course, if its in the correct FORUM is another story)

Ok, first, the breakdown.. I have a PHPmotion script running as a BACKEND. My users will ony see the videos via a "popup" (loose term) player I am working on. (long story, will elaborate only if I must)

So I'm pulling the Video "Channels" from the Database, and populating a Dropdown with them. No problem there.

Now I want to refresh the page with videos from the selected channel. I tried $_POST to simply return the value of the DropDown as a test, and come up with absolutely nothing.

Here's what I have in the form

<form id="form1" method="post" action="showvids.php">
                <input type="hidden" name="chan_sel" value="videos_channel">
				  <p>
				    <select name="videos_channel" id="videos_channel">
				      <?php
do {  
?>
				      <option value="<?php echo $row_Recordset1['channel_name']?>"><?php echo $row_Recordset1['channel_name']?></option>
				      <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
	  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  }
?>
			        </select>
			       <input type="submit" name="button" id="videos_channel" value="Go">
				  </p>
			  </form>

And in the "showvids.php"

<?php echo $_POST['videos_channel'];?>

The resulting page is as plain white as a winter day here in Iowa.

I might mention I'm while not a "Novice" at PHP, I'm not 100% comfortable with it yet. I at least have my toes in the water

The loop is before the mysql query... try to put backward

<?php
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
      $row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
do {  
?>
				      <option value="<?php echo $row_Recordset1['channel_name']?>"><?php echo $row_Recordset1['channel_name']?></option>
				      <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
?>

That broke everything. I lost the values in my dropdown.

I think you might be misunderstanding the problem. I have no problem populating the dropdown from the database. Thats done already. The problem I'm having is passing the value of the dropdown once the "go" button is pressed.

I tried simply passing the value of the dropdown to a separate page using $_POST and the RESULTING page is blank, not the dropdowns.

The site passes validation test (http://validator.w3.org/) ?

Common situations with blank pages is due to a syntax error, and error reporting isn't enabled, cache fault... Try to use print_r or var_dump($_POST) if does make a difference.

Firstly, your loop should be a while, not a do-while. (A do-while will always run at least once even if your condition fails which you don't want).

Secondly, would you post your code that's handling the POST. All we see now is your form.

@ martin5211 - I haven't gotten as far as validation yet. I'm still in development stages, and will approach that when I have things more solid.

Ok This is the page with all the Queries that is used up to this point

<?php require_once('Connections/videosDB.php'); ?>
<?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";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_videosDB, $videosDB);
$query_Recordset1 = "SELECT channels.channel_name FROM channels ORDER BY channels.channel_name";
$Recordset1 = mysql_query($query_Recordset1, $videosDB) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
	<div id="header">
	  <h2>&nbsp;</h2>
  </div>
	<div id="menu">
		<ul>
			<li><a href="#">Home</a></li>
			<li><a href="#">Schedule</a></li>
			<li><a href="#">Services</a></li>
			<li><a href="#">About Us</a></li>
			<li><a href="#">Contact Us</a></li>
            <li><a href="#">Support FPAC</a></li>
		</ul>
	</div>
	<div id="content">
		<div id="right">
	  <div class="post">
				<form id="form1" method="post" action="showvids.php">
                <input type="hidden" name="chan_sel" value="videos_channel">
				  <p>
				    <select name="videos_channel" id="videos_channel">
				      <?php
do {  
?>
				      <option value="<?php echo $row_Recordset1['channel_name']?>"><?php echo $row_Recordset1['channel_name']?></option>
				      <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
	  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  }
?>
ct>
			      <input type="submit" name="button" id="channel_select" value="Go">
				  </p>
			  </form>

You can see the form I'm using at http://www.fairfieldmediacoop.com/fpactest/videos.php This is a Private Server local to me, so I can change anything I need to as far as Apache and PHP5

The dropdown values are passed from the DB, but when you press GO, it loads a blank page. what I was simply trying to do was pass the result of the dropdown selection to the next page via $_POST. If I can get that to work, I'm pretty sure I can get the rest.

And I'm using Dreamweaver in Code View (Yes I build the original queries and the dropdown population using the Bindings Panel, but I mainly use it for the code view)

I actually meant show the source of showvids.php. There's nothing that I can see wrong with videos.php (aside from the while/do-while fix).

The following data is being sent to showvids.php if I select Conversations with Swami Satyanada

button          Go
chan_sel        videos_channel
videos_channel  Conversations with Swami Satyananda

So the page is working correctly, its showvids.php that's failing.

HAH Copied/pasted all that for nothing LOL

showvids.php

<?php echo $_POST['channel_name'];?>

HAH Copied/pasted all that for nothing LOL

showvids.php

<?php echo $_POST['channel_name'];?>

As you can see from my previous post there is no data called channel_name . Your select box is named videos_channel .

There is only button , chan_sel , and videos_channel

When a blank page happens, you can do simply on the action page

echo '<pre>'; print_r($_POST);

to see what variables are being passed

As you can see from my previous post there is no data called channel_name. Your select box is named videos_channel.

There is only button,chan_sel, and videos_channel

That did it. Sonofa.. Change to echo $_POST['videos_channel']; and it worked like a charm.. THANK YOU

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.