patk570 42 Newbie Poster

Revision again, I got it working:

<!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>Calc Price</title>
<SCRIPT LANGUAGE="JavaScript">
function  doMath() {
var one = eval(document.theForm.elements[0].value)
var two = eval(document.theForm.elements[1].value)
var outp = "" 
	{
    ans = one*two
    outp = " " + "$" + ans + ".00" + "/Month"

}
  document.getElementById('outtab').innerHTML = outp 
} 
</SCRIPT>
</head>
<body>
<div>
<form name="theForm">
<p>Please select:</p>
<select name="one">
  <option>1</option>
  <option>2</option>
  <option>3</option>
  <option>4</option>
  <option>5</option>
  <option>6</option>
  <option>7</option>
  <option>8</option>
  <option>9</option>
  <option>10</option>
</select>

<p>Price</p>
$<input name="two" DISABLED type="text" size="4" value="2.00">

<BR><BR>Total:<SPAN ID="outtab"></SPAN>
<br><BR>
<input type="button" onclick="doMath()" value="Calculate Total" >
</form>
</div>
</body>
</html>
patk570 42 Newbie Poster

i DIDNT add the full code, sorry...here is a revision to it...

<!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>Calc Price</title>
<SCRIPT LANGUAGE="JavaScript">
function  doMath() {
var one = eval(document.theForm.elements[0].value)
var two = eval(document.theForm.elements[1].value)
var outp = "" 
var prod = document.times.mult.value 
    ans = one*two
    outp =  ans 

}
  document.getElementById('outtab').innerHTML = outp 
} 
</SCRIPT>
</head>
<body>
<div>
<form name="theForm">
<p>Please select:</p>
<select name="one">
  <option>1</option>
  <option>2</option>
  <option>3</option>
  <option>4</option>
  <option>5</option>
  <option>6</option>
  <option>7</option>
  <option>8</option>
  <option>9</option>
  <option>10</option>
</select>

<p>Price</p>
$<input name="two" DISABLED type="text" size="4" value="2.00">

<BR><BR>Total:<SPAN ID="outtab"></SPAN>
<br><BR>
<input type="button" onclick="doMath()" value="Calculate Total" >
</form>
</div>
</body>
</html>
patk570 42 Newbie Poster

Trying to figure out why this SIMPLE math function will not work. If anyone can help me that would be great....Thanks

<!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>Calc Price</title>
<SCRIPT LANGUAGE="JavaScript">
function  doMath() {
var one = eval(document.theForm.elements[0].value)
var two = eval(document.theForm.elements[1].value)
var prod = one*two
var outp = "" 

}
  document.getElementById('outtab').innerHTML = outp 
} 
// End -->
</SCRIPT>
</head>
<body>
<div>
<form name="theForm">
<p>Please select:</p>
<select name="one">
  <option>1</option>
  <option>2</option>
  <option>3</option>
  <option>4</option>
  <option>5</option>
  <option>6</option>
  <option>7</option>
  <option>8</option>
  <option>9</option>
  <option>10</option>
</select>

<p>Price</p>
$<input name="two" DISABLED type="text" size="4" value="2.00">

<BR>Total:<SPAN ID="outtab"></SPAN>
<br>
<input type="button" onclick="doMath()" value="Calculate Total" >
</form>
</div>
</body>
</html>
patk570 42 Newbie Poster

See i am not to sure what i want. I do have a Javascript calendar, but thats about it for JS, I want something new that is going to catch attention at the bottom of the page in the 3 boxes there. I mean would like to have a recipe or maybe some tidbits of things at the bottom, I have a MYSQL db in place, so its not hard to add a table, and throw in some data, but I just want something different at the bottom there.

patk570 42 Newbie Poster

Hello everyone, I am a beginner at PHP, and I have been working with some php code, I built a search result page, a random string generator and a few other ones. But I would like to get a new idea for the website I am working on. I am not sure what to do. Also I am going to incorporate a login page, but that is not coming till later on. I want to add some really cool functions to the bottom of my website in 3 boxes that i have setup, you can view them here Familyrecipesonline.net Please give me some ideas, as i am bored with the ones i have lol.

Thanks
Patrick :)

patk570 42 Newbie Poster

OK so i solved the issue i was getting. But this new thing is presenting its self. When I click on the name i want...it doesnt render any information on the page, its just blank. I am going to upload my code as it is in my DB and see if there is an issue that i am overlooking....Hope it is small....

<?PHP
    
	mysql_connect("omit","omit","omit"); 
	
	mysql_select_db("omit") or die("Unable to select database"); 

    $output = "";
    if(isset($_GET['search'])){
    $search = mysql_real_escape_string($_GET['search']);
    $r = mysql_query("SELECT ID, Customer_Name FROM Client_Computer_Info WHERE Customer_Name LIKE '%{$search}%'");
    if(mysql_num_rows($r)>0){
    $output .= "\n<ul>";
    while($d = mysql_fetch_array($r)){
    $output .= "\n\t<li><a href=\"search.php?id={$d['ID']}\">{$d['Customer_Name']}</a></li>";
    }
    $output .= "\n</ul>";
    }else{
    $output = "<p>Sorry no results for that name.</p>";
    }
    }elseif(isset($_GET['Customer_Name'])){
    $id = intval($_GET['ID']);
    $r = mysql_query("SELECT Customer_Name, Computer_Type, Computer_Make, Computer_Model, Serial_Number, Product_Number, OS, `Key` FROM Client_Computer_Info WHERE Customer_Name = $id LIMIT 1");
    if(mysql_num_rows($r) == 1){
    $d = mysql_fetch_array($r);
    $output .= "\n<p>Name: {$d['Customer_Name']}</p>
    \n<p>Computer Type {$d['Computer_Type']}</p>
    \n<p>Computer Make {$d['Computer_Make']}</p>
    \n<p>Computer Model {$d['Computer_Model']}</p>
    \n<p>Serial Number {$d['Serial_Number']}</p>
    \n<p>Product Number {$d['Product_Number']}</p>
    \n<p>OS {$d['OS']}</p>
    \n<p>Key {$d['`Key`']}</p>";
    }else{
    $output = "<p>Sorry the ID supplied for the customer does not exist.</p>";
    }
    }
    ?>
    
<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Search</title>
</head>

<body>
    <form id="fsearch" name="fsearch">
    <label for="search">Search user:</label>
    <input type = "text" name="search" id="search" placeholder="Enter the user..." />
    <input type = "submit" name="submit" id="submit" value="Search Users" />
    </form>
    
    <?php echo $output;?>
</body>

</html>
patk570 42 Newbie Poster

OK Guys, one last error and it should work like a charm. I am now getting error: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /homepages/36/d301143136/htdocs/MyDB/search.php on line 12

I used the code above, Ill repost it with changes:

<?PHP
    session_start(); 
    //connect to your database ** EDIT REQUIRED HERE **
	mysql_connect("localhost","omit","omit"); //(host, username, password)

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

    $output = "";
    if(isset($_GET['search'])){
    $search = mysql_real_escape_string($_GET['search']);
    $r = mysql_query("SELECT ID, Customer_Name FROM customers WHERE Customer_Name LIKE '%{$search}%'");
    if(mysql_num_rows($r)>0){
    $output .= "\n<ul>";
    while($d = mysql_fetch_array($r)){
    $output .= "\n\t<li><a href=\"search.php?id={$d['cust_id']}\">;{$d['Customer_Name']}</a></li>"
    }
    $output .= "\n</ul>";
    }else{
    $output = "<p>Sorry no results for that name.</p>";
    }
    }elseif(isset($_GET['Customer_Name'])){
    $id = intval($_GET['ID']);
    $r = mysql_query("SELECT Customer_Name, Computer_Type, Computer_Make, Computer_Model, Serial_Number, Product_Number, OS, `Key` FROM customers WHERE customer_id = $id LIMIT 1");
    if(mysql_num_rows($r) == 1){
    $d = mysql_fetch_array($r);
    $output .= "\n<p>Name: {$d['Customer_Name']}</p>
    \n<p>Computer Type {$d['Computer_Type']}</p>
    \n<p>Computer Make {$d['Computer_Make']}</p>
    \n<p>Computer Model {$d['Computer_Model']}</p>
    \n<p>Serial Number {$d['Serial_Number']}</p>
    \n<p>Product Number {$d['Product_Number']}</p>
    \n<p>OS {$d['OS']}</p>
    \n<p>Key {$d['Key']}</p>";
    }else{
    $output = "<p>Sorry the ID supplied for the customer does not exist.</p>";
    }
    }
    ?>
    
<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Search</title>
</head>

<body>
    <form id="fsearch" name="fsearch">
    <label for="search">Search user:</label>
    <input type = "text" name="search" id="search" placeholder="Enter the user..." />
    <input type = "submit" name="submit" id="submit" value="Search Users" />
    </form>
    
    <?php echo $output;?>
</body>

</html>

Any ideas?

patk570 42 Newbie Poster

Here is the code like you said to put it in with my connect string. But i am getting the error described above. Any ideas?

<? PHP
    session_start(); 
    //connect to your database ** EDIT REQUIRED HERE **
	mysql_connect("localhost","omit","omit"); //(host, username, password)

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

    $output = "";
    if(isset($_GET['search'])){
    $search = mysql_real_escape_string($_GET['search']);
    $r = mysql_query("SELECT ID, Customer_Name FROM customers WHERE Customer_Name LIKE '%{$search}%'");
    if(mysql_num_rows($r)>0){
    $output .= "\n<ul>";
    while($d = mysql_fetch_array($r)){
    $output .= "\n\t<li><a href=\"search.php?id={$d['cust_id']}\">{$d['Customer_Name']}</a></li>"
    }
    $output .= "\n</ul>";
    }else{
    $output = "<p>Sorry no results for that name.</p>";
    }
    }elseif(isset($_GET['Customer_Name'])){
    $id = intval($_GET['ID']);
    $r = mysql_query("SELECT Customer_Name, Computer_Type, Computer_Make, Computer_Model, Serial_Number, Product_Number, OS, `Key` FROM customers WHERE customer_id = $id LIMIT 1");
    if(mysql_num_rows($r) == 1){
    $d = mysql_fetch_array($r);
    $output .= "\n<p>Name: {$d['Customer_Name']}</p>
    \n<p>Computer Type {$d['Computer_Type']}</p>
    \n<p>Computer Make {$d['Computer_Make']}</p>
    \n<p>Computer Model {$d['Computer_Model']}</p>
    \n<p>Serial Number {$d['Serial_Number']}</p>
    \n<p>Product Number {$d['Product_Number']}</p>
    \n<p>OS {$d['OS']}</p>
    \n<p>Key {$d['Key']}</p>";
    }else{
    $output = "<p>Sorry the ID supplied for the customer does not exist.</p>";
    }
    }
    ?>
    
<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Search</title>
</head>

<body>
    <form id="fsearch" name="fsearch">
    <label for="search">Search user:</label>
    <input type = "text" name="search" id="search" placeholder="Enter the user..." />
    <input type = "submit" name="submit" id="submit" value="Search Users" />
    </form>
    
    <?php echo $output;?>
</body>

</html>
patk570 42 Newbie Poster

My SQL connect string

patk570 42 Newbie Poster
Parse error: syntax error, unexpected T_STRING in /homepages/36/d301143136/htdocs/MyDB/search.php on line 3
patk570 42 Newbie Poster

OK so i amended the PHP code for what you had, i inserted the Connection string that i have and it doesn't work. to connect to the db. Like i said i am kinda a noob at this. Can you affix the connection string to the code as well? so i know where it goes...

patk570 42 Newbie Poster

Upon logging into the DB, You come to a screen that has 2 buttons, One to add information and the other to search. I have the search on its own page and that's it. Its an internal DB for my company and I got this far but that's it. lol. I am not a php programmer or anything. I just want it to show the details for the information i have in there. The search box is only one page then it renders the other page with the results.

patk570 42 Newbie Poster

Yeppers, but where do I include that code at? I have it set for the form to be this:

<div align="center">
<form name="form" action="search.php" method="get">
Please enter &quot;CLIENT NAME&quot; into search box<br>
<input type="text" name="q">
<input type="submit" name="Submit" value="Search">
</form>
</div>

Then i do have a DB connection string attached to the PHP code i supplied. just omitted it...But where do i insert that at for the code to work properly with the existing code i have.

patk570 42 Newbie Poster

Sorry, it is a lil confusing.

I want to run the query, and when it shows the results, i want it to have a clickable link on the name(Customer_Name) when it generates. When i click on the name i want it to show all results of the DB for that Customer, I have 8 Fields defined and i want to be able to see the results.

patk570 42 Newbie Poster

I have a basic search result page going right now, but i want the code to generate a html link on the search name so I can see all the data associated with the customer name. I have a simple DB set up with Customer Name, Computer type, Model, etc. The search does show the name and if there is multiple in there for the customer but I am stuck on how to make the name clickable and show all the results of the DB for that user.

Here is the search code:

<?php

  // Get the search variable from URL

  $var = @$_GET['q'] ;
  $trimmed = trim($var); //trim whitespace from the stored variable

// rows to return
$limit=10; 

// 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)

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

// Build SQL Query  
$query = "select * from Client_Computer_Info where Customer_Name like \"%$trimmed%\"  
  order by ID"; // 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: …