You are here: sending flash variable to php file « All PHP « IT news, forums, messages
sending flash variable to php file

Posted by WhiteJediGuy on 06/07/05 06:58

Hi.. I have been working on a site for about 6 months now and I am using
PHP, MySQL, and Flash (and other programs, such as Dreamweaber, but that is
besides the point). I am working on a search for inside the catalog at
http://playersmusic.com/ and I was hoping if someone could evaluate it, the
search portion that is and see if they can find the issue I have been
dealing with. The issue is that whenever someone types something into the
search, say "Blah," it says that there are zero results found for it, but
then it shows the "next button." Another thing is that I have a flash banner
at the top duplicated amongst all of the pages with the search box in it,
for some reason I can't seem to find anything that would show how to
transfer the search term onto the php page. It would go from them typing in
a word on whatever page they are on into the search box, click "go", then it
would go to "search.php" but it keeps saying what is should say when nothing
has been entered. It works when on the actual page, for it is just html and
php, but I can't get the flash to transfer the variable. I am using the get
method.

here is the code for the search.php:


<?php
// Get the search variable from URL
@$var = $_GET['search'];
$trimmed = trim("$var"); //trim whitespace from the stored variable
// rows to return
$limit=10;
//
?>
<html>
<head>
<? echo "<title>Search Results for $var</title>";?>
</head>
<body>
<form name="form" action="search.php" method="get">
<?
echo "<input type='text' name='search' value=$var>";
?>
<input type="submit" name="Submit" value="Search" />
</form>
<?
// check for an empty string and display a message.
if ($trimmed == "")
{
echo "<p>Please enter a search...</p>";
exit;
}

// check for a search parameter
if (!isset($var))
{
echo "<p>We dont seem to have a search parameter!</p>";
exit;
}

//connect to your database ** EDIT REQUIRED HERE
**//////////////////////////////
@mysql_connect("Host","Username","Password"); //(host, username,
password)///

//specify database ** EDIT REQUIRED HERE **
@mysql_select_db("e95rdez_catalog") or die("Unable to select database");
//select which database we're using

// Build SQL Query
$query = "select * from products where idNumber like \"%$trimmed%\"
order by idNumber"; // EDIT HERE and specify your table and field names
for the SQL query

$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);



// If we have no results, offer a google search as an alternative

if ($numrows == 0)
{
echo "<h4>Results</h4>";
echo "<p>Sorry, your search: &quot;" . $trimmed . "&quot; returned zero
results</p>";

//google
echo "<p><a href=\"http://www.google.com/search?q="
. $trimmed . "\" target=\"_blank\" title=\"Look up
" . $trimmed . " on Google\">Click here</a> to try the
search on google</p>";
}



// next determine if s has been passed to script, if not use 0
if (empty($s)) {
$s=0;
}

// get results
$query .= " limit $s,$limit";
$result = mysql_query($query) or die("Couldn't execute query");

// display what the person searched for
echo "<p>You searched for: &quot;" . $var . "&quot;</p>";

// begin to show results set
echo "Results";
$count = 1 + $s ;

// now you can display the results returned
while ($row= mysql_fetch_array($result)) {
$title = $row["idNumber"];

echo "$count.)&nbsp;$title" ;
$count++ ;
}

$currPage = (($s/$limit) + 1);

//break before paging
echo "<br />";

// next we need to do the links to other results
if ($s>=1) { // bypass PREV link if s is 0
$prevs=($s-$limit);
print "&nbsp;<a href=\"$PHP_SELF?s=$prevs&search=$var\">&lt;&lt;
Prev</a>&nbsp&nbsp;";
}
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from
division

if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
// check to see if last page
if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {

// not last page so give NEXT link
$news=$s+$limit;

echo "&nbsp;<a href=\"$PHP_SELF?s=$news&search=$var\">Next &gt;&gt;</a>";
}
$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
echo "<p>Showing results $b to $a of $numrows</p>";
//script help @ http://www.designplace.org
?>
</body>
</html>

I pretty much would need the actionscript for transfering the variable from
the Flash to the search.php page.

Thanks in advance
webmaster of playersmusic.com
WhiteJediGuy.tk

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация