Motorider 0 Light Poster

Well Sir I have been living in Mr.and Mrs. PHP and SQL 's home the last two days. Reading and trying different angles to the code above with no success.

First off, no insult to you. That bit above taught me about joins and conditional statements and much more. And I'm still looking at it.

In any case, it doesn't appear to have primary / foreign keys.

SELECT * FROM ig_deals AS d INNER JOIN ig_categories AS c INNER JOIN x AS ig_city ON ig_deals.shop_id = ig_deal_shops.shop_city_idWHERE ig_category.cat_type != 1 AND ig_deals.deal_category = 4
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in all_deals.php on line 42

$sql = 'SELECT * FROM ig_deals AS d INNER JOIN ig_categories AS c INNER JOIN x AS ig_city ON ig_deals.shop_id = ig_deal_shops.shop_city_id';

41.  $result = mysql_query($sql);
42.  if(!mysql_num_rows($result))
Motorider 0 Light Poster

I don't even know anymore.

thanks anyway

Motorider 0 Light Poster

Kind Sir, Thank you for your patience with me.

Everything is working fine. What I am trying to do is limit the viewership of the Members Only shopping catagory, cat_id=4 to logged in members only. While still showing the Members Only catagory link. If a person should select (click) the Members only link it should check for login and perform accordingly. The CURRENCY function shows the currency symbol in the displayed data.

When the Membership Catagory is clicked
check for login
If user is logged in then proceed and show content
If user is not logged in redirect to login page

I appreciate what you have shown me so far, I have learned much from it and I see the direction that you are going with the previous.

$logged = (isset($_SESSION['user_id'])) ? $_SESSION['user_id'] : 0;
$cat = fetch_array(...); //your user-defined function
if($cat['cat_type'] == 0)
{
$content = show_category($cat); //use a function to avoid code duplication
}else{
$content = (logged) ? show_category($cat) : 'Please log in to see this category';
}
function showCategory($cat)
{
$output = ...;
return output;
}
//further on
<div id="content">
echo $content;
</div>

but I don't know how to put it together.

Since this week I have been studying my php pages extensiveley and I have found that most access to restricted information is funneled through a single action page of which seems to use the case switch or statement. Could we intergrate and add to this page with the cat_type switch we created?

You …

Motorider 0 Light Poster

No time crunch, no problem, it had just been a few days.

thank you

Motorider 0 Light Poster

Are we done here? Did I do something wrong?

Motorider 0 Light Poster

I have been studying this and I'm not getting it.
It seems that the arrays are the actual headings?

<tr>
    <td><?php echo $array['Value']; ?></td>
    <td><?php echo $array['Discount']; ?></td>
    <td><?php echo $array['Deal Amount']; ?></td>
    <td><?php echo $array['You Save']; ?></td>
</tr>

Where data displays from the Database.

<tr>
    <td><?php echo CURRENCY($deal_fetch["deal_actual_amount"]); ?></td>
    <td><?php echo $deal_fetch["deal_percentage"].'%'; ?></td>

    <td><?php echo CURRENCY($deal_fetch["deal_deal_amount"]); ?></td>
    <td><?php echo CURRENCY($deal_fetch["deal_saving_amount"]); ?></td>
</tr> 

Variables:

$alldeals_query = "SELECT * FROM ig_deals WHERE deal_status=1 AND $searchby '$now' BETWEEN deal_start_date_time AND deal_end_date_time ORDER BY RAND()";

    $deal_query = mkr_query($alldeals_query);

    $deal_fetch = fetch_array($deal_query);

I don't know how to put it together.

Motorider 0 Light Poster

In the same post regarding the cat_type filter it is indicated to define which arrays to be collected and displayed in a div content. Alas my ignorance is showing again.
How do I do this seamlessly with the following table html placed within the "all deals" container div. You might remember the "all deals div comes after the else statement above within the html and this table displays the deal information from the database.

<table >
    <tr>

    <td align="center" class="value"><?php echo $array['Value']; ?></td>
    <td align="center" class="value"><?php echo $array['Discount']; ?></td>

    <td align="center" class="value"><?php echo $array['Deal Amount']; ?></td>

    <td align="center" class="value"><?php echo $array['You Save']; ?></td>
       </tr>
       <tr>
    <td align="center" class="index_amt"><?php echo CURRENCY($deal_fetch["deal_actual_amount"]); ?></td>

    <td align="center" class="index_amt"><?php echo $deal_fetch["deal_percentage"].'%'; ?></td>

    <td align="center" class="index_amt"><?php echo CURRENCY($deal_fetch["deal_deal_amount"]); ?></td>

    <td align="center" class="index_amt"><?php echo CURRENCY($deal_fetch["deal_saving_amount"]); ?></td>

        </tr>    
   </table>
Motorider 0 Light Poster

okay I'm back and have worked further on this problem.

Your Post 2043374

Indicated that there was still some holes in what I called a final. so I reworked it and came up with this and it seems to work splendidly. I hope you like it better.

      if(isset($_GET["cat_id"])) {
          $h1 = ucwords($_GET["cat_name"]);
    } 
          elseif(isset($_SESSION["city_search"]) && ($_SESSION["city_search"] != 'all')) {
          $h1 = "DEALS IN" . $array['Deals in '].ucfirst(str_replace(" ", "&nbsp;", $search_city_name));
    }     elseif(isset($_GET["city_id"]) && $_GET["city_id"] == "all")
 {
         $h1 = $array['All Deals'];    //put this back in for now 
 }   else {
          $h1 = "ALL DEALS" ;
 }
         $h3center = 'Sorry, no deals now!';

and;

     <h1><?php echo $h1; ?></h1>

     <hr class="hr_small" />
<div class="content_left_bottom_left_description_other">             
   <?php
         if($deal_num_rows <= 0)
    {
         $reduce_right = 1;
  ?>            
     <h3><?php echo $h3center ?></h3>
   <?php
    }
        else{
  ?>
Motorider 0 Light Poster

Internet problems today and will be out of town until Sunday.

Motorider 0 Light Poster

So from the origional goal here is what I wish to do:

  1. IF SESSION IS NOT SET OR NOT LOGGED IN
  2. SHOW ONLY CAT_TYPE="0"
  3. IF CAT_TYPE="1" IS SELECTED
  4. CHECK FOR SESSION OR LOGIN
  5. IF LOGGED IN SHOW CONTENT
  6. ELSE
  7. REDIRECT TO LOGIN PAGE
Motorider 0 Light Poster

BINGO! Heres how it ended up.

    if(isset($_GET["cat_id"])) {
        $h1 = "" . ucwords($_GET["cat_name"]);
    } elseif(isset($_SESSION["city_search"]) && ($_SESSION["city_search"] != 'all')) {
        $h1 = "DEALS IN" . $array['Deals in '].ucfirst(str_replace(" ", "&nbsp;", $search_city_name));
    } elseif(isset($_GET["city_id"]) && $_GET["city_id"] == "all")
    {
    }
        else {
        $h1 = "ALL DEALS" ;
    }
    {
        $h3center = "Sorry, no deals now!" ;
    }

And.

<div class="content_left_bottom_other" style="margin-top:0;">
    <h1><?php echo $h1; ?></h1>
    <hr class="hr_small" />
<div class="content_left_bottom_left_description_other">             <?php
        if($deal_num_rows <= 0)
    {
        $reduce_right = 1;
?>
    <h3><center><?php echo $h3center; ?></center></h3>
<?php
    }

        else
    {
?>
<div class="alldeals_banner">
Motorider 0 Light Poster

The $h1 array echos the catagory names when the catagory is selected but does not echo the "All Deals" when on the all deals landing page and no category selected.

I am also doing something wrong with the $h3 echo as well because it does not output "sorry no deals now" when the catagory is empty.

Motorider 0 Light Poster

I'm not sure about the div closing I was doing an edit on the post trying to indent it correctly. The closing is in the page file but it may have been missing before as I was doing an edit while you posted.
The whole code is like this and contains almost 5000 files I think.

I thought it one to learn on when I purchased it but it is jumbled up and doesn't really align with the coding tutorials. I think it confuses me more that anything.

If I could find the right mentor / instructor I would pay to learn how to code my site from scratch.

I am however where I am at today. chuckle

Motorider 0 Light Poster

Front end images

Motorider 0 Light Poster

Ok I have installed your updated code. Had some little errors with the syntax and how it lines up. anyway it is at a place where it is working.

The $h1 array echos the catagory names when the catagory is selected but does not echo the "All Deals" when on the all deals landing page and no category selected. I am also doing something wrong with the $h3 echo as well because it does not output "sorry no deals now" when the catagory is empty.

 <div class="content_left_bottom_other" style="margin-top:0;">

     <h1><?php echo $h1; ?></h1>

            <hr class="hr_small" />
            <div class="content_left_bottom_left_description_other">             
<?php
        if($deal_num_rows <= 0)
    {
            $reduce_right = 1;

            echo $h3center;
    }

else
    {
?>
                    <div class="alldeals_banner">
                    <table width="100%">
                    <tr>
                        <td width="46%" rowspan="10" valign="top"><a href="index.php?id=<?php echo $deal_fetch["id"]; ?>"><img src="<?php echo $single_deal_image; ?>" alt="image" height="320" width="300"/></a></td>
                        <td width="54%" valign="top"><h1 style="margin:0; padding:0;"><?php echo ucfirst(substr($deal_fetch["deal_name"], 0, 33)); ?></h1></td>
                    </tr>

The else statement continues on to the alldeals_banner. More of a jumble I'm afraid. I'm sure there is a place for it at the top but I couldn't figure it out.

}
    else
{
    ?>
    <div class="alldeals_banner">

I have been looking at this for hours and I don't know what to do next.

Motorider 0 Light Poster

I thought it looked a little jumbled too but I thought it best for it to wait for some advanced study or refining. I will be away for 6hrs.

Thank you.

Motorider 0 Light Poster

Yeah I want to learn. That is why I came to Daniweb. However I am interested and seeking a more comprehensive outline for training for the first of the year. I thank you for your support! Here goes;

The code for the unordered list of category selections is above. Also there is the area that dispays the contents of the category selection.

<div class="content_left_bottom_other" style="margin-top:0;">
                <h1 class="h1"><?php if(isset($_GET["cat_id"])) { echo ucwords($_GET["cat_name"]); } elseif(isset($_SESSION["city_search"]) && ($_SESSION["city_search"] != 'all')) { echo $array['Deals in '].ucfirst(str_replace(" ", "&nbsp;", $search_city_name)); } elseif(isset($_GET["city_id"]) == "all") { echo $array['All Deals']; } else { ?><?php echo $array['All Deals'];?><?php } ?></h1>
                <hr class="hr_small" />
                <div class="content_left_bottom_left_description_other"> 
                <?php
                if($deal_num_rows <= 0)
                {
                    $reduce_right = 1;
                    echo "<h3><center>".$array['Sorry, no deals now!']."</center></h3>";
                }
                else
                {
                ?>

So I am thinking,

<?php
{
$where = "WHERE cat_id = $cat_id";
if(!$logged) $where .= " AND cat_type = 0";
}   
    else{
header("Location: login.php");
exit();
}
?>

And I don't know where to put it. In the fetch or the display. Also in the construct I'm thinking there should be a get for the cat_type

if(isset($_GET["cat_type"]))
Motorider 0 Light Poster

diafol, I am still here. Truth is I have been studying my code all this time but I don't think I'm up to par on my skills. I was able to create the cat_type field but after that I am at a loss. I see the logic in your direction but I don't know what to do with it on my own.

I am inclined to close out this thread and seek some professional tutoring or a seminar. Perhaps you might have guidance for me regarding a wise choice with that as well.
I thank you for your time and attention.

Sincere

Motorider 0 Light Poster

Thank you for your response.

The session start is found in the library.php common file includes. The other session_id checks are on pages served, such as the checkout page and user information page.

The query or catagory fetch is contained in the code above I believe and it is placed in a "right column include file". Viewers may select product catagories and view the contents but I wish to reserve a private catagory for "members only / logged in users". So I am trying to restrict views of "cat_id=4". Rather than require login to view all catagories and to provide them as a preview.

So I only need to check the session on the fetching of catagory 4.

I thank you for the else statement. I was hung up on the if. I also have a prestashop that I stumble around in but there is tons of tutorials for this software. This daily deals software I purchased from a company.

I am well versed in html and css and I wish to learn the programing side of my websites. Are you still interested in guiding me from here?

Thank you for your consideration.

Motorider 0 Light Poster

I have a Daily Deals website of which I desire to limit the viewing of one of the product catagories to logged in users only. here is the catagory code.

<div class="categories">
<h3><?php echo $array['Categories'];?></h3>
<ul>
    <?php 
        $category_total  = num_rows(mkr_select('ig_category','cat_name,cat_id,cat_image','cat_status=1'));
        $category_select = mkr_select('ig_category','cat_name,cat_id,cat_image','cat_status=1 ORDER BY cat_name ASC  LIMIT 0,3');
        if(num_rows($category_select)>0)
        {
            while($fetch_category = fetch_array($category_select))
            { 
            ?>
        <li><a href="all_deals.php<?php echo $urladdon; ?>cat_id=<?php echo $fetch_category['cat_id']; ?>&cat_name=<?php echo $fetch_category['cat_name']; ?>" <?php if($_GET["cat_id"] == $fetch_category['cat_id']) { ?>class="categoriesactive" <?php } ?>><?php echo strtoupper($fetch_category['cat_name']); ?></a></li>
        <?php
            }
        ?>
        <?php
            $category_select2 = mkr_select('ig_category','cat_name,cat_id,cat_image','cat_status=1 ORDER BY cat_name ASC LIMIT 3,50');
            while($fetch_category2 = fetch_array($category_select2))
            {
        ?>
        <li class="tgl"><a href="all_deals.php<?php echo $urladdon; ?>cat_id=<?php echo $fetch_category2['cat_id']; ?>&cat_name=<?php echo $fetch_category2['cat_name']; ?>" <?php if($_GET["cat_id"] == $fetch_category2['cat_id']) { ?>class="categoriesactive" <?php } ?>><?php echo strtoupper($fetch_category2['cat_name']); ?></a></li>
        <?php
            }
            if($_GET["cat_id"] == "")

            {
                if($category_total>=3)
                {
                ?>
                <li class="more"><a style="cursor:pointer; text-align:right; font-size:12px;" id="viewall_a"><?php echo $array['View']; ?>&nbsp;&gt;&gt;&nbsp;</a></li>
                <?php
                }
                ?>
                <li class="less"><a style="cursor:pointer; text-align:right; font-size:12px;" id="viewall_b"><?php echo $array['View']; ?>&nbsp;&lt;&lt;&nbsp;</a></li>
                <?php
            }
        }
        ?>
</ul>
</div>

Here is the portion I believe that concerns what I am trying to do.

<?php
            $category_select2 = mkr_select('ig_category','cat_name,cat_id,cat_image','cat_status=1 ORDER BY cat_name ASC LIMIT 3,50');
            while($fetch_category2 = fetch_array($category_select2))
            {
        ?>
        <li class="tgl"><a href="all_deals.php<?php echo $urladdon; ?>cat_id=<?php echo $fetch_category2['cat_id']; ?>&cat_name=<?php echo $fetch_category2['cat_name']; ?>" <?php if($_GET["cat_id"] == $fetch_category2['cat_id']) { ?>class="categoriesactive" <?php } ?>><?php echo strtoupper($fetch_category2['cat_name']); ?></a></li>
        <?php
            }
            if($_GET["cat_id"] == "")

I know first I must check for the session if(isset($_SESSION[""])) so if session is set show the requested content "cat_id=4". If session is unset direct viewer to login page. unset($_SESSION["login.php"]);

Am I anywhere …

Motorider 0 Light Poster

Seems to be a tough one. The only solution I can find is;

<meta name="format-detection" content="telephone=no" />

Still would like the phone number link to work. Will leave the thread open for a few more days.

Motorider 0 Light Poster

I just finished a site that list three zip codes as a service area.
when the site is viewed in smart phone browsers the three zip codes become linked to Google maps or it tries to offer the zip as a call now phone feature. when the wrong zip is clicked the mapping service is unable to locate the map.

Can anyone help me please resolve this.

Thanks

Motorider 0 Light Poster

I have been playing around with liquid websites and Ive pretty much got it down except for the text.

When designing for a smaller screen size the text becomes too small when viewed in a larger screen. And visa versa when designed for a larger screen size the text becomes to large when scrunched down on a smaller monitor and doesn't allow the containing div to adjust to a smaller size.

Does anybody know how to get around this.

Thanks for your response.

Motorider 0 Light Poster

You might try inserting a streaming flv and put divs on top of it. there will probably be some sort of page border but it should work. Wouldn't that be on the same premise as html5 but with a flv? It's gonna be a huge file unless you shorten and loop. I don't know this is basically my first year so I am just starting out. Everything is experimental with me.

activeden.net has a couple of flash templates along this idea.

Motorider 0 Light Poster

I have done some experimental work in this area. Flash is the way to go using layers.

Presumably you could do it in HTML5.

Motorider 0 Light Poster

Ah yes the span tag!

#navigation span{
font-style:oblique;
color:#ff00e5;
font-size:2em;
margin-left:1em;
}

ul
{
float:left;
padding:0;
margin:0;
list-style-type:none;
}

This grasshoppa is very grateful!

Motorider 0 Light Poster

Okay, I know. As a certified webmaster I should be able to figure this out. but... could someone please help me.

I am trying to place some text to the right of navigation links, within the same div.

here is the html

<div id="navigation">

<ul>
<li><a href="#">Welcome</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Store</a></li>
<li><a href="#">Magazine</a></li>
<li><a href="#">Calender</a></li>
<li><a href="#">Policy</a></li>
<li><a href="#">Contact</a></li>
</ul>
<p>West Hampden Avenue Denver Co XXX-000-X0X0</p>

</div>

Here is the CSS

#navigation{
border-style:solid;
border-color:#3f6635;
width:100%;
height:26px;
background-color:#5c3566;
}

ul
{
padding:0;
margin:0;
list-style-type:none;
}

li {
display:inline;
font-size:1.55em;
}

Here is a jpeg showing what I am trying to accomplish.

Thank you for your response.

Motorider 0 Light Poster

Thanks EF!! Other than a few code tweeks worked first time!

Motorider 0 Light Poster

I have searched for a solution to this problem on daniweb and google to no avail. You folks have been so kind as to help me before.

This portfolio piece, slash website for my father incorporates a MySQL PHP search form in the left div, and the search results in the right div.

My intent is to have the .png file appear in the results div upon the first landing of the visitor. To be replaced by the visitors search results. Possibly with a link in case the visitor would like to see it again.

Could someone please point me in the right direction?

ardav?

Motorider 0 Light Poster

Alright finally solved the riddle after maddening hours of trying everything I could think of. Simplified it down to no formatting just a form, code, and echo. And it wouldn't work. It was then that I thought to myself what would happen if I saved it with a .php extension. Wallah it all came together. In the dozen or so tutorials I have read, I don't remember it being a clear point. The simplified code is below.

Thank you very much for your help!

<!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">
 
<body> 
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
 
    
	<label for="mytype">Type:</label>
	<select name="mytype" id="mytype">
    <option value="1">GM</option>
    <option value="2">MCI</option>
    <option value="3">Engines</option>
	</select>

	<label for="desc">
<br/>
<br/>
	Description:</label>
	<input type="text" name="desc" id="desc" />
    <input type="submit" name="submit" value="Submit" /> 
	</form>

</body> 
</html>


<?php

//Create an empty variable
$search_result = '';

//If statement, to check if the submit button has been clicked.
if (isset($_POST['submit'])) {

//Connect To Database

include "config.php"; //config.php contains login information for mysql_connect

mysql_connect($hostname,$username,$password) OR DIE ('Unable to connect to database! Please try again later.');
mysql_select_db($dbname);


$mytype = $_POST['mytype']; //this is an integer
$term = $_POST['desc']; //this is a string
	
$sql = mysql_query("select * FROM products WHERE description like '%$term%' AND product_type_id = '{$mytype}'");
	
while ($row = mysql_fetch_array($sql)) {
	// Use the variable to build and format the result
	$search_result .=  '<br/> Part No: '.$row['part no'] . "\n";
	$search_result .=  '<br/> Description: '.$row['description'] . "\n";
	$search_result .=  '<br/> Price: '.$row['price'] . "\n";
	$search_result .= …
Motorider 0 Light Poster

Simon, again, I thank you for your help. I am new to php and this is my first project.

The script seems to be trying to work (no errors) but doesn't display the results. I have been playing with it all day but with my limited knowledge I can't make it show the results.

On php.net it says that since echo is a language construct that it can't be used with variable functions. Is this why the results don't display?

Motorider 0 Light Poster

Simon, Thanks for your response. I can see or feel the direction your going. And I studied the information in your post today, but I don't yet have the knowledge to put it together.

I know its a lot to ask, but could you give me some code to play with?

I know about the form action <form method="post" action="<?php echo $_SERVER['PHP_SELF'];"> I need more help with the variable, using this variable, echoing the variable and displaying the results. A div is already setup to contain the results. The if statement as well.

Thanks

Motorider 0 Light Poster

If this should be posted in another area, such as, layout and design please let me know. A person who post's as Ardav on this board has gotten me this far.

I have a relational database that pulls by brand and descriptive keyword. I wish to search and display on the same page. Allowing people to search again without using the back or a link button. Displaying the search form, and related text contained to left half of the page and the search results displayed in a column format on the right half of the page.

My search page code is;

<html> 
    
<head> 
        
<title>Bus Parts Search</title> 
    <link href="test.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
<!--
.style1 {font-size: 12pt}
.style2 {font-size: 12px}
-->
    </style>
</head> 
 
<body>
<div>
<div class="banner"><img src="graphics/stainlessbg2copy.jpg" width="950" height="125"></div>
    
<div class="cont"></div>

<div class="head1">
  <h4><u>Search Parts Here</u></h4>
  <h4 class="style1">First Select type. </h4>
  <h4 class="style1">Enter part description keyword<br>
  and submit.</h4>
  <h4 class="style1">To see a complete list of parts<br>
    on hand for a type.<br>
    Submit with description blank.</h4>
  </div>

<div class="search">  
	<form action="results2.php" method="post"> 
    
	<label for="mytype">Type:</label>
	<select name="mytype" id="mytype">
    <option value="1">GM</option>
    <option value="2">MCI</option>
    <option value="3">Engines</option>
	</select>

	<label for="desc">
<br>
<br>
	Description:</label>
	<input type="text" name="desc" id="desc" />
    <input type="submit" name="submit" value="Submit" /> 
	</form>
</div>


<div class="results">Content for  class "results" Goes Here</div>
</div>
</body> 
</html>

My PHP code is;

<?php
//Connect To Database
$hostname='';
$username='';
$password='';
$dbname='';


mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
mysql_select_db($dbname);



$mytype = $_POST['mytype']; //this is an integer
$term = $_POST['desc']; //this …
Motorider 0 Light Poster

Final error solved. The offenses were the capitol letters in echo results. (see code first post's)

while ($row = mysql_fetch_array($sql))
{
    echo 'ID: '.$row['ID'];
    echo '<br/> Part No: '.$row['Part No'];
    echo '<br/> Description: '.$row['Description'];
    echo '<br/> Price: '.$row['Price'];
    echo '<br/><br/>';
}

Since the label fields in the tables are lower case.

Works Great!

Motorider 0 Light Poster

I did manually insert the corresponding values in the product table.

Following the suggestions in post #4 I setup my products table with a column for prod_id. Perhaps you suggested this because I did have an id field in the old table. May I delete this column because I don't need it. And if this is not the cause can I assume that I need to set my primary key again in the product_types table?

Motorider 0 Light Poster

Okay solved the error. It was the extra quote and semicolon;

$sql = mysql_query("select * from products where Description like '%$term%' AND product_type_id = '{$mytype}'");";

Now my DB connects, but echos the headings without the retrieved results.

ID:
Part No:
Description:
Price:

Am I correct to believe the that there is still an error within the above mysql_query statement? Or, did I not link up my tables correctly? Also the prod_id within my products table has no data or value.

Oh my head hurts. LOL

Motorider 0 Light Poster

Oh boy Iv'e done something wrong I get;

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/j/i/m/jimsbusparts/html/results2.php on line 30

Line 30 is;

echo 'ID: '.$row['ID'];
Motorider 0 Light Poster
prod_id	part_no	description          price product_type_id
0	23501554Fuel crossover hose	              0	0
0	9 r 512	primary pump filter hose	0	0
0	4l 20 199	Air compressor hose	0	0
0	10g 264	Transmission to filter hose	0	0
0	16k 11 91	Discharge compressor	0	0
0	6k 71	Air compressor hose	0	0
0	10 g 257	Air compressor hose	0	0
0	700092	Discharge compressor	0	0


type_id	label
0	GM
0	MCI
0	Engines
Motorider 0 Light Poster

ardav,

Thank you for your response. I am so sorry that it is taking so long to resolve this. Demands have been placed on me this week.

I have set up the tables as you have suggested, except leaving out the quantity and condition fields within the products table and have uploaded a database.

If I did this correctly the label field contains MCI GM and Engines in the product_types table.

I am unsure how to set up the id fields.

Thanks again.

Motorider 0 Light Poster

Ok Josh I have read through the jquery website and I am going to need your help to continue. If your still willing.

I have added the above code to my search form.

Motorider 0 Light Poster

The drop down chooses the appropiate table and the keyword text box should cull the appropiate part from the selected table. For example, if MCI is selected in the drop down and the keyword is hose, the results should list all of the hoses in the MCI table.

Or, if MCI is chosen in the drop down and a part number is entered into the keyword text, it should return the corresponding part as a result. (I havent entered the part numbers into the table yet)

Thanks for your response.

Motorider 0 Light Poster

I do have the $_POST in the file so I am assuming that I have a syntax error somewhere.

I started the project this way because I thought this would be the elementary way to begin learning and do have plans to improve it to a relational database as I move along. This is my dads website and while the scroll bars are functional It seemed to be the ideal real world situation to learn from. Perhaps I am taking the wrong approach to learn PHP.

I appreciate your comments because it seems to make more sense to me as I further investigate the manual and other resources.

Thank you.

Motorider 0 Light Poster

Ardav you the man! I once again feel like I am getting somewhere. However, now that the drop down is selecting the tables, the keyword search is not functioning. It pulls all records within the designated table ignoring the keyword and or part number. Any suggestions?

I am a newly certified web designer but the school I went to didn't cover any programming lessons other than web page design. Since I am out of money I am hoping I can learn PHP on my own. Or rather, with help from folks such as yourself. I thank you!!

I understand what you mean by ($_POST) cleanup but, I am lost as to what you mean by 'real_escape' , 'addslash' and 'html_entities' .

Thanks again for your help.

Motorider 0 Light Poster

I am seeking help to create a html search form that has a drop down box listing tables within a mysql database that contain parts for different makes of buses.

The idea is that the drop down list would select the table and the part would be found within the selected table by keyword description or part number with a text box.

The table catagories and contents can be seen here. http://www.jimsbusparts.com

A working simple search without the drop down can be seen here. http://www.jimsbusparts.com/search1.html

My html is;

<form action="results.php" method="post"> 
    
    <p>
      <select name="select" id="select">
        <option>MCI</option>
        <option>GM</option>
        <option>Engines</option>
      </select>
    </p>
    <p>Part Name: 
      <input type="text" name="term" />
      <br /> 
   
      <input type="submit" name="submit" value="Submit" /> 
        </p>
  </form>

My php code so far is;

mysql_select_db("xxxxxxx", $con);

$term = $_POST['term'];

$sql = mysql_query("select * from MCI where Description like '%$term%'");

while ($row = mysql_fetch_array($sql))
{
	echo 'ID: '.$row['ID'];
	echo '<br/> Part No: '.$row['Part No'];
	echo '<br/> Description: '.$row['Description'];
	echo '<br/> Price: '.$row['Price'];
	echo '<br/><br/>';
	}

?>

I realize that there is more involved regarding form validation and security but I am having trouble wrapping my mind around php coding. If someone could first help me get the basic search working step by step and then add the refinements after I think I might be able to grasp it.

I would be most grateful.