Jump to content

stoni23

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Everything posted by stoni23

  1. actually... I'm running into a new problem. Before it would get any phone number to work... but now it doesn't recognize phone numbers that have non numerical symbols in them.
  2. you have saved my life... it's working. It's displaying as an array, but that's fine I can easily have it display by row. Thanks a ton for the help.
  3. I tried that and it actually made an infinite loop that had the number 1 and then an <hr> all the way down the page.
  4. I forgot to mention that I've left out some of the fields from the tables, because my first goal is simply to get this thing to function... and display the correct value from each of the three tables. I'll worry about the semantics like getting it to display the specific values later. I'm only concerned about making it work for now.
  5. Before I start, I'll point out that I'm a newbie and trying to do most of the coding myself, using a previously working search function. Anyway, I'll explain the predicament as best as I can. In a bit of pickle on this current task. My cart program has three different tables that it uses to complete an order. The tables are orders, cart, and cartoptions. My client wants to be able to search a phone number and a 6 digit pin and have it pull certain information. Only problem is that the 6 digit pin is on the cartoptions table and the phone number is on the orders table. The only reason I need the cart table is because he wants other information to display, and it's located on the cart table. The only way these tables have similar values is as follows: ordSessionID from the orders table matches cartSessionID from the cart table. and then cartID from the cart table matches coCartID from the cartoptions table. Hopefully I haven't lost everybody. Anyway, I've started with code that I used from a different search function that does work. And I'm able to search on the orders table and post the results perfectly. But, when it pulls information from the cartoptions and the cart tables it is displaying every single value from whatever field I attempt to display, when I'm only wanting to display the ones that match up with the correct variables. So I've managed to pull information from the appropriate tables, but I haven't figured out how to connect all three tables together appropriately... I've seen online there are ways to join two tables, but that doesn't help me because I'm using three tables. Anyway, here's the code: <?php session_start(); include('vsadmin/db_conn_open.php'); // Search Form Processor $ordPhone = mysql_real_escape_string($_POST['ordPhone']); $sql = ""; $sql2 = ""; $sql3 = ""; // SQL SELECT if(isset($_POST['searchordPhone'])){ $sql = "SELECT * FROM orders WHERE ordPhone LIKE '{$ordPhone}%'"; }//end if if(isset($_GET['query'])){ $query = $_GET['query']; $sql = "SELECT ordPhone, ordSessionID FROM orders WHERE ordPhone = '{$query}'"; $sql2 = "SELECT cartSessionID, cartID FROM cart WHERE cartSessionID = '{$ordSessionID}'"; $sql3 = "SELECT coCartID FROM cartoptions WHERE coCartID = '{$cartID}'"; }//end if ?> <body> <form name="searchordPhone" method="post" action="<?php $PHP_SELF; ?>"> Enter Phone Number:<br /> <input name="ordPhone" type="text" id="ordPhone" size="20"><br /> <input type="submit" name="searchordPhone" id="search" value="Search"> </form><br /> <br /><br /><br /> <?php if($sql !== ""){$result = mysql_query($sql); if(mysql_num_rows($result) > 0){while($row = mysql_fetch_assoc($result)){ echo $row['ordPhone']."<br>"; echo $row['ordSessionID']."<br>"; }//end wh }else{ print "<tr><td colspan=\"3\" class=\"description\">There are no results to display</td><td> </td></tr>"; }//end if }//end if ?> <?php if($sql2 !== ""){$result = mysql_query($sql2); if(mysql_num_rows($result) > 0){while($row = mysql_fetch_assoc($result)){ echo $row['cartSessionID']."<br>"; }//end wh }else{ print "<tr><td colspan=\"3\" class=\"description\">There are no results to display</td><td> </td></tr>"; }//end if }//end if ?><?php if($sql3 !== ""){$result = mysql_query($sql3); if(mysql_num_rows($result) > 0){while($row = mysql_fetch_assoc($result)){ echo $row['coCartID']."<br>"; }//end wh }else{ print "<tr><td colspan=\"3\" class=\"description\">There are no results to display</td><td> </td></tr>"; }//end if }//end if ?> </body> I'm probably way off here by declaring extra sql variables. I just didn't know how else to take this, so if anybody has some pointers I would be in their debt.
  6. turns out that I forgot to change the physician to Physician in my search form. Thanks a ton for all your help! : ) SELECT * FROM doctors WHERE Physician LIKE 'whateverityped%' was what was echoing if i added an echo $sql; statement in the loop.
  7. good noticing the non capitalization, thank you for noticing that. I've fixed that in my code, now they're Physician instead of physician. But, unfortunately that did not solve my problem. Another thing I forgot to mention, no matter what input I give the search, I get the same results (the entire database). I could search for a 900 letter long string and still yield the entire database of results.
  8. Hey guys, I'm a php newbie that's trying to learn php on the job, and my deadline is quickly approaching. I'm attempting to learn php through a book, which is working just fine. The only problem is it's somewhat of a slow process. Anyway, I'm trying to search using a physicians name from a database of names and return only the values that are relevant to that search. Results displayed will be all fields for that record. The table is organized as follows: Physician - Specialty - Street - City - State - Zip - Phone I've managed to have it display the entire database (which is 883 doctors long), but I'm having difficulty making it display only relevant information. I'm not getting any errors, but I can't seem to figure out what I'm doing wrong. I'm only trying to display physicians and city to see if I can make it work. Once I get the right code in I was going to expand it to include all 7 fields. Also, if somebody wants to say I'm posting too much code, then I'll shrink it down to more relevant information. I don't want to annoy anybody here lol. Also, I've double checked my database connections, they are all working properly. If anybody can assist me or point me into the right direction on how I can narrow my search results to display only relevant information I would greatly appreciate it. Thanks in advance. <?php session_start(); // Check for login // Call DB Connection include('includes/db_conn.php'); // Search Form Processor $Physician = $_POST['physician']; $sql = ""; // SQL SELECT if(isset($_POST['searchPhysician'])){ $sql = "SELECT * FROM doctors WHERE Physician LIKE '{$physician}%'"; }//end if if(isset($_GET['query']) <> ""){ $query = $_GET['query']; $sql = "SELECT Physician, Specialty, Street, City, State, Zip, Phone FROM doctors WHERE Physician = '{$query}'"; $result = mysql_query($sql); }//end if ?> <body> <h1 class="redLL">Major Topic Search</h1><br> <!-- TITLE SEARCH --> <form name="searchphysician" method="post" action="<?php $PHP_SELF; ?>"> <table width="100%" border="0" cellspacing="0" cellpadding="1"> <tr> <td width="23%" class="description"><p>Search by Name</td> <td width="63%"><input name="physician" type="text" id="physician" size="20"></td> <td width="14%"><input type="submit" name="searchPhysician" id="search" value="Search"></td> </tr> </table> </form><br /> <table border="0" class="table" width="85%" cellspacing="2" cellpadding="2"> <tr> <td class="description" width="20%"> Physician </td> <td class="description"> City </td> </tr> <?php if($sql !== ""){ $result = mysql_query($sql); if(mysql_num_rows($result) > 0){ while($row = mysql_fetch_assoc($result)){ print "<tr> <td>".$row['Physician']."</td> <td>".$row['City']."</td> </tr>"; }//end wh }else{ print "<tr><td class=\"description\">There are no results to display</td><td> </td></tr>"; }//end if }//end if ?> </table> </div> <br><br> </body> </html>
  9. stoni23

    Hello

    Hello all, my name is Jeff and I am a newbie to php programming. Hopefully, I can assist and be assisted using these forums here. Thanks for allowing me to use these forums as I'm sure they will be helpful to me.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.