PHP/MySQL - Nav links pass variable to another page? Or?

I'm a PHP/MySQL beginner. I'm digging through books and tutorials as best I can, but finding myself a little lost in the sheer volume of information. If someone can point me in the right direction for this task, I'd really appreciate it.
I have a database (MySQL) with two tables. One is a list of carpets, and the other a list of the categories of carpets and information about those categories.
The "carpets" table has a field for each record to indicate which category that carpet belongs to.
I'm trying to do this:
- A navigation bar listing the categories
- When you click on a category, a "gallery" page opens, display the carpets (name, description, photo) of each carpet in that category
Does Dreamweaver have server behaviors for this? If not, can anyone give me a general idea of what the code is I need to write to make this happen?
Thanks VERY much in advance,
Patty Ayers | www.WebDevBiz.com
Free Articles on the Business of Web Development
Web Design Contract, Estimate Request Form, Estimate Worksheet

David,
I believe I've done exactly what you described above; only my naming is slightly different.
catID in my database is "category_id"
page.php in my application is "navbar.php"
detail.php in my application is "gallery.php"
When I view navbar.php in the browser and click on one of the links, the resulting URL is like this:
gallery.php?2=
or
gallery.php?3=
etc.
I'm pasting the whole code from navbar.php and gallery.php below, in case it's is helpful for you to have a look at it (and you have the time to).
I am really grateful for your help.
Patty
------------ navbar.php ----------------------------------------------------------------------------------------- ---------------------
<?php require_once('Connections/connSouthwest.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  if (PHP_VERSION < 6) {
    $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_connSouthwest, $connSouthwest);
$query_GetCategories = "SELECT * FROM categories";
$GetCategories = mysql_query($query_GetCategories, $connSouthwest) or die(mysql_error());
$row_GetCategories = mysql_fetch_assoc($GetCategories);
$totalRows_GetCategories = mysql_num_rows($GetCategories);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Navbar</title>
</head>
<body>
<ul>
  <?php do { ?>
    <li><a href="gallery.php?<?php echo $row_GetCategories['category_id']; ?>="><?php echo $row_GetCategories['category_name']; ?></a></li>
    <?php } while ($row_GetCategories = mysql_fetch_assoc($GetCategories)); ?>
</ul>
</body>
</html>
<?php
mysql_free_result($GetCategories);
?>
----------------- gallery.php -----------------------------------------------
<?php require_once('Connections/connSouthwest.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  if (PHP_VERSION < 6) {
    $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;
$maxRows_GetCarpet = 10;
$pageNum_GetCarpet = 0;
if (isset($_GET['pageNum_GetCarpet'])) {
  $pageNum_GetCarpet = $_GET['pageNum_GetCarpet'];
$startRow_GetCarpet = $pageNum_GetCarpet * $maxRows_GetCarpet;
$colname_GetCarpet = "-1";
if (isset($_GET['category_id'])) {
  $colname_GetCarpet = $_GET['category_id'];
mysql_select_db($database_connSouthwest, $connSouthwest);
$query_GetCarpet = sprintf("SELECT * FROM carpets WHERE category_id = %s ORDER BY carpet_sort ASC", GetSQLValueString($colname_GetCarpet, "int"));
$query_limit_GetCarpet = sprintf("%s LIMIT %d, %d", $query_GetCarpet, $startRow_GetCarpet, $maxRows_GetCarpet);
$GetCarpet = mysql_query($query_limit_GetCarpet, $connSouthwest) or die(mysql_error());
$row_GetCarpet = mysql_fetch_assoc($GetCarpet);
if (isset($_GET['totalRows_GetCarpet'])) {
  $totalRows_GetCarpet = $_GET['totalRows_GetCarpet'];
} else {
  $all_GetCarpet = mysql_query($query_GetCarpet);
  $totalRows_GetCarpet = mysql_num_rows($all_GetCarpet);
$totalPages_GetCarpet = ceil($totalRows_GetCarpet/$maxRows_GetCarpet)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Category Name | Southwest Looms</title>
</head>
<body>
<h1>Gallery Page</h1>
<p>Category Name will go here.<br />
  Category Description will go here. </p>
<p></p>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
  <?php do { ?>
    <tr>
      <td><?php echo $row_GetCarpet['carpet_photo_thumb']; ?></td>
      <td><?php echo $row_GetCarpet['carpet_name']; ?>: <?php echo $row_GetCarpet['carpet_description']; ?></td>
    </tr>
    <?php } while ($row_GetCarpet = mysql_fetch_assoc($GetCarpet)); ?>
</table>
<p> </p>
</body>
</html>
<?php
mysql_free_result($GetCarpet);
?>

Similar Messages

  • Need help passing variables to another jsp page

    I am working in a shopping cart with multiple lines and I am wanting to pass 2 variables to another page which is accessed from a link.
    What I have so far is the following:
    This is on the shopping cart JSP page with the link
    <input type="hidden" name="shopCartReqDate1<%=i%>" id="shopCartReqDate1<%=i%>" value="<%= retVals[9] %>">
    <input type="hidden" name="shopCartExpDate1<%=i%>" id="shopCartExpDate1<%=i%>" value="<%= retVals[10] %>">
    Need it Earlier?
    I am wanting to pass it to the HAC_Help_Text_Need_it_Earlier.jsp page
    Right now on the HAC_Help_Text_Need_it_Earlier.jsp page I have the following code:
    String shopCartReqDate1 = IBEUtil.nonNull(request.getParameter("shopCartReqDate1"));
    String shopCartExpDate1 = IBEUtil.nonNull(request.getParameter("shopCartExpDate1"));
    Do I need to create a function and do a document.getElementById?
    Thanks for the help!

    As far as I understand your question You don't have to use document.getElementById. Just submit the form and then on the next page You'll just pull the variables out from the request object.

  • How do I display # symbol in PHP to refer to an anchor on another page?

    How do I display # symbol in PHP to refer to an anchor on
    another page?
    I am updating a record and using a dynamic anchor name for
    the page to forward to like this:
    seeAllEntriesXcodeAsc.php#<?php echo
    $row_getProductsWithSAMEcode['id']; ?>
    But I keep getting an error, I think its because its reading
    the # hash sign as a PHP instruction rather than an anchor hash...
    Is there are way to mark it up so as to use the # as part of the
    URL ?
    I have even tried referring to a dummy field with a hash in
    like this - but that doesn't work either.
    seeAllEntriesXcodeAsc.php<?php echo $_POST['hash'];
    ?><?php echo $row_getProductsWithSAMEcode['id']; ?>
    Thanks!

    Sorry, I will try and explain in a different way...
    I have a page in php where a database has an entry added,
    changed or deleted.
    The page is posted to an in between page to process the
    transaction (which works)...
    You are then taken to a dynamic anchor of the entry on a
    database summary page to the SAME entry to see that the change has
    been done.
    (So the basic problem is that the link to take to the anchor
    needs to have a # hash symbol in the middle to denote the anchor,
    but the URL that is created puts the # at the end of the URL rather
    than directly before the link the php code generates... All I need
    is a way to code a PHP URL that manages a # hash in the middle.)
    So in the middle processing page, I have update an entry
    transaction with the page to redirect to after undertaking the
    transaction as:
    seeAllEntriesXcodeAsc.php#<?php echo
    $row_getProductsWithSAMEcode['id']; ?>
    So the final URL error I get is this:
    Parse error: syntax error, unexpected
    T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or
    T_NUM_STRING in
    /secure/c/capitalgarden/admin/DeleteEntryProcessor.php on line 39
    The file is too large to post here so I have saved the file
    as an HTML file so you can read the code at this URL:
    http://www.new.capital-garden.com/DeleteEntryProcessor.html
    Thanks for your help!
    C

  • Can't access adobe from my smart phone to use my form created in formscentral I receive an error message that says "unsupported browser". There is a link to download a supported browser but the link directs me to another page that says "browser no

    When I try to access adobe from my smart phone to use my form created in formscentral I receive an error message that says "unsupported browser". There is a link to download a supported browser but the link directs me to another page that says "browser not supported at this time". This happened to me while using my IPhone 5, a friend that uses an IPhone 6, and another friend that uses a Samsung Galaxy S5. I just need for my employees to be able to access, complete and submit work orders created in formscentral from their phones. I would like to use the data collection feature in formscentral but at this point any suggestions on how to accomplish this are welcomed. Thank you

    Further info - I changed my security settings to allow apps from anywhere, and again tried to install.  I again got an error message
    that the update failed to install, and to contact Customer Support.

  • Importing variables from another page in jsp

    Hey.
    I want to make two pages. I want the first page to include the variables from another page or POJO.
    I did this but i cant use the variables in index.jsp without initializing them first. But when I initialize them i get an error when trying to initialize them two times.
    if i use the variable in index without saving i get an error in eclipse.. but it works if i save and deploy.
    Is there any way to make eclipse see that i have imported the variable?
    The pages look something like this:
    index.jsp
    <%@ include file="extra.jsp" %>
    Print the number from the extra page
    <%= number %>extra.jsp
    int number = 32;I plan using this in a much greater system so I would appreciate any help.

    I'm having the same problem.
    Would be nice if somebody could help us.

  • Javascript: to pass values to another page

    hi all,
    i hav an interactive report. if i clik on a particular row, that row values must be passed to an another page (via javascript)
    i found this forum https://forums.oracle.com/thread/2467579 in which they hav used it for sending mail.
    but i wanted to pass those values to another page throug javascript bz, i hav installed a plugin nd wrking from it under right clik.
    ma  javascript function  is,
    function func(action,el, pos)
       window.location ="http://apex.oracle.com/pls/apex/f?p=71510:2:&SESSION.:::2:P2_X,P2_X2:'+ $(el).children('td[headers="EMPNO"]').text() +  ',' + $(el).children('td[headers="ENAME"]').text()";
    here i hav redirected it to the 2nd page and in the 2nd page i hav used 2 items to get these values.
    $(el).children('td[headers="EMPNO"]').text() +        ------->  this is to fetch the empno of that particular row and similarly for the name.
    but if i click on the right clik button , no action is happening... 
    but its working fine, if i use the function as,
    function func(action,el, pos)
       window.location ="http://apex.oracle.com/pls/apex/f?p=71510:2:&SESSION.";
    so somewhere is going wrong in passing the values in URL i suppose....
    and i hav used al d above things in
    http://apex.oracle.com/pls/apex/f?p=71510:1 (username: test / paswrd: pex14gm)
    pls help me out.....
    thanks in advance

    Try like this.
    function func(action,el, pos){
        var empNum = $(el).children('td[headers="EMPNO"]').text();
        var eName  = $(el).children('td[headers="ENAME"]').text();
        window.location ='http://apex.oracle.com/pls/apex/f?p=71510:2:&SESSION.:::2:P2_X,P2_X2:'+empNum+','+eName;
    It looks simple and neat.
    If you still didn't get post me workspace details.

  • [php+mysql] how to pass a variable to a page in a frameset

    Hi all,
    I have a problem with a php page sending a variable to a page
    contained in
    a frameset.
    In the base page I have a link that sets a variable
    (basepage.php&link=mylink) and loads a frameset.
    How can I read this variable in a page contained in the
    frameset?
    What are the possible solutions?
    I have to use frameset since the customer WANTS a music file
    playing while
    surfing the website. So, I created a frameset and loaded the
    music on a
    frame that will NOT change/reload during navigation. Is there
    an
    alternative that will allow me to load pages without
    interrupting the base
    music?
    TIA
    Tony ;)

    > I know David certainly doesn't encourage them in his
    books - but why o
    > why are these authors and publishes so content just to
    rehash all the
    > old out of date web techniques.
    Because they are hacks.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "Malcolm _" <[email protected]> wrote in message
    news:[email protected]..
    > On Thu, 17 Jul 2008 12:01:11 +0100, David Powers
    <[email protected]>
    > wrote:
    >
    >>Michael Fesser wrote:
    >>> Of course using sessions on a frame site might
    cause new problems and a
    >>> slower download because of file locking.
    >>
    >>That's why frames are "evil". ;-)
    >
    >
    > I was in Waterstones bookshop today - and as you do -
    had a browse at
    > the computer bookshelfs.
    >
    > An attractive book titled Website design - and published
    in 2008.
    >
    > And guess what - still detailing frames and what they
    can do for your
    > website, and no mention of the downsides of using them.
    > No wonder so many newbies are still confused.
    >
    > I know David certainly doesn't encourage them in his
    books - but why o
    > why are these authors and publishes so content just to
    rehash all the
    > old out of date web techniques.
    >
    > --
    >
    > ~Malcolm~*...
    > ~*

  • Pass data from a variable to another page

    Hi,
    I have a "select one choice" field from a page. I want to pass the data from that field to another page.
    Any ideas on how to do it?
    Thanks!

    drag and drop a list form data control onto your page as SOC.
    In the value change event get value like, valueChangeEvent.getNewValue()
                                            <af:selectOneChoice value="#{bindings.Return.inputValue}"
                                                                label="Plan:"
                                                                autoSubmit="true"
                                                                unselectedLabel="Please select a value
                                                                id="soc1"
                                                                valueChangeListener="#{MyBean.planValueChangeEvent}">
                                                 <af:forEach items="#{bindings.Return.items}"
                                                             var="pln">
                                                      <af:selectItem label="#{pln.label}"
                                                                     value="#{pln.value}" id="si3"/>
                                                 </af:forEach>
                                            </af:selectOneChoice>

  • Equating a passed variable to another variable??

    I have a simple 3 part setup as follows...
    1 JSP, 1 Java Class, 1 Interface for the class
    I want the JSP file to pass a variable to the java class which contains the name of a variable in the interface. (e.g. a String called "name", the variable name in the interface contains "Bob Smith") How do I get java to equate what is in the passed variable ("name") to what is contained in the name variable of the interface("Bob Smith"). Hopefully I explained this with enough detail to understand, but if I didnt, let me know.
    -Adam Wachtel

    Nevermind, I'm going to switch the flow of data so I dont have to do that.

  • Passing data to another page loaded in the same window

    How to pass data from a page to another when new page loading
    takes place ?
    I use :
    window.htmlLoader.load( new air.URLRequest("app:/" +
    htmlfilename));
    I tried :
    window.htmlLoader.addEventListener(air.Event.CHANGE,
    passmonitor)
    but it doesn't work !

    The problem is in passing the variables . As I mentioned
    above,, the following error message gets displayed:
    Can't get property window from undefined value
    The code I tried is
    myloader = window.htmlLoader.load(new air.URLRequest("app:/"
    + filen ));
    myloader.window.somevar = "data";

  • Link from report to another page

    I have a report with form construction. The report lists Things. Thing has columns ID,NAME,DESC. The ID (Edit button) via the wizard is linked to the form and it works fine. Next I wanted to have the NAME column link to another page (page 27) whose content is generated by a PLSQL procedure as the region source. The PLSQL uses the bind variable :P27_ID to determine which record to select. On the reports page Column Attributes for NAME I have target page in this application (27) and in the Items List I have Name of P27_ID and value of #ID#. I hoped this would work like the link to the Form page but it doesn't quite. The problem is on Page 27 I wind up with the record for the previous time I clicked a NAME in the report list. It's like one behind. I'm missing something obviously.

    Anonymous - Sometimes the session state gets corrupted when you're developing an application, like if you rename an item for example. If logging out/logging in permanently fixed the issue, it was probably something like that.
    Scott

  • A Link with parameters to another page in a report

    Hi, I need to pass a link to another page with parameter, all in a report - But I can't use the column link because I already use to another link.
    Help!!

    Hi, I need to pass a link to another page with
    parameter, all in a report - But I can't
    use the column link because I already use to
    another link.
    Help!!Why not read the values from the calling page in the new page? They are there and available.. If you call page 2 from page 1, all the items on page one are available to page 2...
    Thank you,
    Tony Miller
    UTMB/EHN

  • Passing values to another page with %

    I have a button that redirects to another page in my application. I am passing the value of one my fields to the target page via <Set These Items> and <With These Values>. The source field has a % at the end of it. When the value gets passed to the target, the % is not passed. Is there a problem passing values with % in them?
    Here is the passing parameter list:
    Set These Items: P22_DB_NAME
    With These values: &P2_DB_NAME.
    The value of P2_DB_NAME is "ESB%". When it gets to the target page it is "ESB".

    Brian,
    you will need to encode the percent sign and use
    %25
    instead of
    Make your button an url and use this link. It will replace the percentage with the encoded value and pass the value to the specified item.
    redirect('f?p=&APP_ID:22:&SESSION.::::P22_DB_NAME:'+$x('P2_DB_NAME').value.replace(/%/, '%25'));
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    ------------------------------------------------------------------------------

  • Process - Pass values to another page

    Procedure for passing parameters.
    Hi
    I have a report region on my page, where the each record have a checkbox to reference a Identifier..
    I want to pass all identifiers referring to the checkbox selected to another page.
    For this I created an item called: P20010_NIVEIS_SEL .. I put the values in it and his step to another item on another page.
    But is not working.
    The process is this:
    DECLARE
    BEGIN
      IF htmldb_application.g_f01.COUNT <= 1 THEN
          : P20010_NIVEIS_SEL: = htmldb_application.g_f01 (1);
      ELSE
        FOR i IN 1 .. htmldb_application.g_f01.COUNT LOOP
          : P20010_NIVEIS_SEL: =: P20010_NIVEIS_SEL | | ',' | | htmldb_application.g_f01 (i);
        END LOOP;
          : P20010_NIVEIS_SEL: = SUBSTR (: P20010_NIVEIS_SEL, 2,: P20010_NIVEIS_SEL.LENGTH);
      END IF;
    END;It´s importante say that to pass the parameters I created a branch to another page, where while the contents of an item to another.
    This giving an error:
    ORA-01008: not all variables are limitedthanks

    Hi,
    Quickly I noticed few mistake. I did not test this, but you could
    DECLARE
    BEGIN
      IF apex_application.g_f01.COUNT <= 1 THEN
          :P20010_NIVEIS_SEL := apex_application.g_f01(1);
      ELSE
        FOR i IN 1 .. apex_application.g_f01.COUNT LOOP
          :P20010_NIVEIS_SEL := :P20010_NIVEIS_SEL | | ',' | | apex_application.g_f01(i);
        END LOOP;
          :P20010_NIVEIS_SEL := SUBSTR(:P20010_NIVEIS_SEL, 2,LENGTH(:P20010_NIVEIS_SEL));
      END IF;
    END;Br,Jari

  • Link to anchor in another page?

    I'm trying to link to an anchor in another page, as opposed
    to the same page. Is this possible? Can I do it using a hotzone
    instead of text?
    I found this but it seems to only want to link to an anchor
    on the same page -
    http://www.uwec.edu/HELP/Dreamweaver8/lnk-target.htm
    Any help much appreciated.

    Yes it is possible.
    In the properties dialog insert the page containing the named
    anchor into the link edit box.
    At the end of the link add #anchor name.
    For example:
    link:
    index.htm#anchorname

Maybe you are looking for