Jump to content

zenix

Members
  • Posts

    29
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

zenix's Achievements

Member

Member (2/5)

0

Reputation

  1. Just curious, why wouldn't I want it in a text box rather than a drop down box? Just curious, very new to programming. Thanks!
  2. Thank you again, I'd actually like to know how to make it so I can click on an entry in the text box and have the fields populate with the associated data. I'd probably more of an AJAX or Javascript issue I guess. I was just hoping to be able to do it with php.
  3. I appreciate your input, thank you. My problem isn't the database...I have THAT working quite well. I would just like to see if I can have the names and maybe phone number of the contacts displayed in a text box so I can click on one and have all the information (address, phone, email etc...) appear in the form.
  4. Hello, I have been working hard this past year trying to learn php and mysql. I've even developed my own little database of contacts. Anyway, I thought it'd be neat (if possible) to have a textarea on the page my data form is on to display the first, last names and phone numbers of the contacts in the db, then have it so all I have to do is scroll through the list and click the one I'd like to have displayed in my form.. I don't know how to do this. My database works great, I just thought this could facilitate a little more learning...and it would be a nice addition. If anyone has any idea on how I might achieve this I'd really appreciate it if you'd let me know. Thanks!!
  5. Thank you for all your guidance, I'll try figuring it out from what you said. You have been a big help to me!
  6. I appreciate all your time and assistance on this, thank you. I tried your example and although it allows me to select an option from the drop down, I don't know how to get all the data associated with this person to be displayed in the form. I have the form all set up and working well, it includes address, address2 city, state and zip, is there a way to have this information populated in the correct fields for the person chosen? Thank you so much again!!
  7. Hello, I am trying to learn php and mysql, and making pretty good progress. I've developed a database for a make believe company and have it working correctly. I thought it'd be neat to have the data (such as last name, first name and phone) appear in a text area at the top or bottom of the form that I use to enter/modify and view my data. I'd like to make it so I can click on an entry in the text area and have the fields of the form populate with the relevant data. Someone mentioned I should use a drop down. I've tried this, I get the info into the drop down alright, but don't know how to go about making the data clickable so the info. fills out the form on the page. I think I'd really prefer a scrolling text area though, but when I try THIS approach I keep getting an error stating that the ...mysql_fetch_array ($result) is not a valid MySQL entry. If someone could help me out, I'd really appreciate it. I've learned a lot this year, apparently I have quite a ways to go. Here is the code I have for the drop down. <?php include("connect.php"); $result = mysql_query("SELECT lname, fname, phone FROM warrantydb ORDER BY lname ASC"); echo "<select name=\"DropData\">"; while($row = mysql_fetch_array( $result )) { //I figure there is a more refined way of doing this, but this works for me. Any thoughts would be appreciated. $Data=$row['lname']; $Data2=$row['fname']; $Data3=$row['phone']; echo "<option>$Data $Data2 $Data3</option>"; } echo "</select>"; ?>
  8. Thanks a lot!! it's something what a simple little typo can do!!
  9. Hi, I was experimenting and decided to try making tabs on a web page, made with php. I have it so the tabs initially display and the contents of tab one shows. When I click on tab 2 none of the contents for that tab show. If I click back on tab 1 there is no contents displayed. I've been wracking my head on this and can't see where my code is wrong. I'd really appreciate it if someone could take a look and help me out. Code for tabs: <?php error_reporting(1); $tabs =array(); function tabs_header() { ?> <style type="text/css"> .tab { border-bottom: 1px solid blue; text-align: center; font-family: arial, verdana; } .tab-active { border-left: 1px solid black; border-top: 1px solid black; border-right: 1px solid black; text-align: center; font-family: arial, verdana; font-weight: bold; } .tab-content { padding: 5px; border-left: 1px solid black; border-right: 1px solid black; border-bottom: 3px solid black; } </style> <?php } function tabs_start() { ob_start(); } function endtab() { global $tabs; $text = ob_get_clean(); $tabs[count($tabs)-1]['text']=$text; ob_start(); } function tab($title) { global $tabs; if(count($tabs)>0) endtab(); $tabs[] = array(title=>$title, text=>"test"); } function tabs_end() { global $tabs; endtab(); ob_end_clean(); $index =0; if($_GET['tabindex']) $index =$_GET['tabindex']; ?> <table width="100%" cellspacing="0" cellpadding="0"> <tr> <?php $baseuri =$_SERVER['REQUEST_URI']; $baseuri =preg_replace("/\?.*$/", "", $baseuri); $curindex =0; foreach($tabs as $tab) { $class ="tab"; if($index ==$curindex) $class ="tab_active"; ?> <td class="<?php echo($class);?>"> <a href=<?php echo($baseuri."?tabindex=".$curindex);?>"> <?php echo($tab['title']);?> </a></td> <?php $curindex +=1; } ?> </tr> <tr><td class="tab-content" colspan="<?php echo(count($tabs)+1);?>"> <?php echo($tabs[$index]['text']);?> </td></tr> </table><?php } ?> Code for index page: <?php error_reporting (1); include('tabs.php'); ?> <html><head><?php tabs_header();?></head> <body> <div style="width:600px;"> <?php tabs_start(); tab("tab one"); echo 'This is the first tab. I am just going to add a little text here to see if it makes any difference at all. '; tab("tab two"); echo "This is the second tab, this is the tab that isn't showing anyting for me when I click on it."; tabs_end();?> </div> </body></html>
  10. Thank you so much everyone!! It's been a headache.
  11. Hi, I am trying to learn php and have been making some pretty good progress. I've just run into a wall though and would REALLY appreciate it if someone could let me know what I am doing wrong. I have this fictitious order form that when filled out a new web page is displayed with the info. and the text is written in tab delimited style to a text file. I'd like to have it so each entry receives its own line. I have utilized \n to no avail, and have tried using <br /> and <p>, none of them give me a new line each time the form is submitted. Thank you in advance! Here is my code. <?php include ('error.php'); $modem = $_POST['modem']; $enet =$_POST['enet']; $sound =$_POST['sound']; $DOCUMENT_ROOT= $_SERVER['DOCUMENT_ROOT']; $fname = $_POST['fname']; $lname = $_POST['lname']; $address = $_POST['address']; $address2 = $_POST['address2']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $phone = $_POST['phone']; ?> <br><br> <html><head><title>ZENIX COMPUTERS</title></head><body> <h1><i>ZENIX COMPUTERS</h1></i> <br> <h2>Order results</h2> <br><p>Order submitted: <?php echo date('H:i, F jS')?> <br><br> <?php $date = date('H:i, F jS'); $find = $_POST['find']; echo "You stated you were referred to us via <b><i> $find</b></i>"; ?> <br><br><?php echo "Your order is as follows:<br>"; echo $modem . 'Modem(s)<br>'; echo $enet .'Ethernet Card(s)<br>'; echo $sound .'Sound card(s)<br>'; ?> <br> <? echo "The subtotal of your order is $tamount";?> <br><? echo "The tax on this order will be $tax";?> <br><? echo "Bringing the total for your order to $grandt";?> <?php $total = 0; $total = $modem +$enet +$sound; if ($total == 0) { echo "You didn't order anyting"; } else { if($modem >0) echo $modem. 'Modem(s)'; if($enet >0) echo $enet. 'Ethernet card(s)'; if ($sound >0) echo $sound. 'Sound card(s)'; } $tamount = 0.00; define('modemp', 19.95); define ('enetp', 19.95); define('soundp', 24.95); $tamount = $modem * modemp + $enet * enetp + $sound * soundp; $tax = $tamount * .08; $grandt = $tamount + $tax; echo 'Items ordered: '.$total.'<br>'; echo 'Your sub total for this order is <font color="blue"><b><i>$'.number_format($tamount,2).'</font></b></i><br>'; echo 'The sales tax will be<b><i><font color="blue">$'.number_format($tax,2).'</font></b></i><br>'; echo '<br>Bringing your total order with tax to<b><i><u><font color="blue">$'.number_format($grandt,2).'</font></b></i></u>'; echo "<br><br>"; $output = '<p>'.$date. "\t".$modem." modem \t" .$enet." Ethernet card \t" .$sound." Sound card\t$" .$grandt." TOTAL\t".$lname." Last\t".$fname." First\t".$address." Address\t".$address2." Address 2\t".$city." City\t".$state." State\t".$zip." Zip\t".$phone."\n"; //append file $fp = fopen("DOCUMENT_ROOT/../orders/orders.txt", 'ab'); if (!$fp) { echo 'Your order could not be processed at this time, please try again later.'; exit; } fwrite($fp, $output, strlen($output)); if($fp) { echo 'DONE!!'; } fclose($fp); echo 'Order written to file'; ?>
  12. UNBELIEVABLE!! Thanks a lot man! Next time I will look a little harder for the obvious, I really appreciate your assistance!
  13. Hi, I am attempting to learn how to make a basic database that will allow input from a user of a web page to be entered into it. I am not the most efficient coder, but I'm learning and I'm new at this. Anyway, I keep getting this error that says for me to check the mysql manual for the right syntax to use near '(test_id) KEY testype(test_lname, test_fname))' at line 4. I can't see anything wrong with it. If someone could guide me in the right direction I'd really appreciate it! Here is the code I've made: ' <?php $conn = mysql_connect('localhost', 'root')or die(mysql_error()); $create = mysql_query("CREATE DATABASE IF NOT EXISTS testdb") or die(mysql_error()); mysql_select_db ("testdb"); //create table $testdb = 'CREATE TABLE test(test_id int (11) NOT NULL auto_increment, test_lname varchar(40) NOT NULL, test_fname varchar(40) NOT NULL PRIMARY KEY(test_id) KEY testype(test_lname, test_fname))'; $result = mysql_query($testdb) or die(mysql_error()); //Create test type table $testype = 'CREATE TABLE testype(testype_id int(11) NOT NULL auto_incrememnt, empl_pos NOT NULL, primary key (testtype_id))'; //create table others $others = 'CREATE TABLE others(others_id int (11) NOT NULL auto_increment, others_mom varchar(40) NOT NULL, others_dad varchar(40) NOT NULL others_bro varchar(40) NOT NULL others_sis varchar(40) NOT NULL PRIMARY KEY(others_id))'; $results = mysql_query($others) or die(mysql_error()); echo 'Database successfully created!'; ?>
  14. Could someone please let me know how to mark this resolved? I'm going to do more troubleshooting and studying. Probably learn better that way. Thank Maq for pointing out my typo. I appreciate all the comments here. Thanks a lot!
  15. Someone already told him that, apparently he did not want php's help in finding basic errors. Yes, I did insert the ini_set('display_errors' 1 ); error_reporting = (E_ALL); sorry it wasn't included here though. Someone told me that it doesn't need to be on every page so I omitted it. More than likely would have been better if I had just left it or even commented it out. Sorry. I also apologize for there having been so much code. I will try to pin point it a little btter in the future. I looked at the post this morning, yeah...it's too much with so many snippets.
×
×
  • 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.