Jump to content

aeafisme23

Members
  • Posts

    121
  • Joined

  • Last visited

    Never

About aeafisme23

  • Birthday 06/25/1983

Contact Methods

  • AIM
    randybennett23
  • Website URL
    http://www.loonar.net

Profile Information

  • Gender
    Male
  • Location
    USA

aeafisme23's Achievements

Member

Member (2/5)

0

Reputation

  1. Just wanted to let everyone know I figured it out using an IF statement if ( $dvd_quantity == 1 ) { $dvd_cost = 25.00;} elseif ( $dvd_quantity == 2 ) { $dvd_cost = 45.00;} elseif ( $dvd_quantity > 2 ) { $dvd_cost = ((15 * $dvd_quantity) + 15); } Thanks for letting me get this far so I was able to noodle it in the right direction!!!!
  2. Thanks for the explaination Alex, makes sense. Unfortunately the page is just white and no error message so it leads me to believe I still have an error in sytnax. Litebearer, thank you for your comment as well. A switch statement may seem more logical but I came across an error as well, it gave me the default error. This is what i tried using your method you suggested: switch ($dvd_cost) { case 1: $dvd_quantity = 1; $dvd_cost = 25.00; break; case 2: $dvd_quantity = 2; $dvd_cost = 40.00; break; case 3: $dvd_quantity > 2; $dvd_cost = 15 * $dvd_quantity; break; default: echo "Sorry we experienced an error"; } a little additional code if it's needed <?php $dvds1 = $_POST["dvds1"]; $dvds2 = $_POST["dvds2"]; $dvds3 = $_POST["dvds3"]; $dvds4 = $_POST["dvds4"]; $dvd_quantity = $dvds1 + $dvds2 + $dvds3 + $dvds4; // QUANTITY if ( $dvd_quantity == "1" ) { $dvd_cost = "25.00";} elseif ( $dvd_quantity == "2" ) { $dvd_cost = "45.00";} else ( $dvd_quantity > "2" ) { $dvd_cost = 15 * $dvd_quantity; } ?>
  3. This is the code that does not work. I want to create the last greater than in the ELSE statement but it does not work, code works up to that point by erasing the else statement and alternatively I could add 100's of elseif to satisfy a quantity and cost but that is not simplified. I know this is a logical and syntax error on my part but I am not sure how i correctly change it? Any help would be great! Thanks guys or gals! <?php if ( $dvd_quantity == "1" ) { $dvd_cost = "25.00";} elseif ( $dvd_quantity == "2" ) { $dvd_cost = "45.00";} else ( $dvd_quantity > "2" ) { $dvd_cost = "15.00*$dvd_quantity";} ?>
  4. Thank you, you top of the include page was pretty much what was wrong, i was defining a variable in the wrong order so on default i was always going to call apple. Thanks again. mrMarcus, thank you for making me laugh
  5. I would like to have a variable in this situation be REPLACED by $orange so that when I echo $apple below it will read the $orange variable from the include and say I am an orange. This is a very dumbed down version of what I am doing and I have 100's of pages that use the include page and each page starts out with declaring $apple=$orange or $apple=$pineapple or in a Generic way I just leave the variable as is. I hope I did not make this more confusing. Content: <?php include("includepage.php"); $apple = $orange; ?> <?php echo $apple; ?> Include Page $apple ="I am an apple"; $orange ="I am an orange";
  6. Maybe this is a better example of what I am trying to do : $eventinfo = "'include("eventinclude.php");' <p class=\"left-align\">Hello this is text.</p>"; Of course I can not get the above to work and tried interchanging the " and the 's many times to no avail. With in the variable I want to execute an include statement along with text. UPDATE: $eventinfo = include("eventinclude.php"); I tried doing that and it is calling the include but it is executing right away and it is not fitting with in the html and where I want it to go it says 1 , just the number one. Is 1 an error code for something?
  7. Thanks for the info on i know what are the major issues of the '" and ;'s but I do not think this is nested inside the variable so when I call the variable $eventinfo it will never execute the mysql code. Any ideas? Thanks
  8. I have about 50 pages that all use variables to display images and text. I did a bad job at coding in the first place and the project is too big to open all 50 pages and insert each statement in when I can use the variable that is there. $eventinfo = "This is just some random text and i want to include some info from my database inside this content // the info below I am trying to contain with in the variable $eventinfo $connect = mysql_pconnect('localhost", "xxxxx", "xxxxx") or die(mysql_error()); mysql_select_db("xxxxx", $connect) or die(mysql_error()); $sql_address = mysql_query("SELECT MAX(ID) as ID, Date, Time FROM events WHERE DMA='$Station'") or die (mysql_error()); $row_count = 0; while($results = mysql_fetch_array($sql_address)) { <tr> <td><p>' .$results['Date'] . '</p></td> </tr> <tr> <td><p>' .$results['Time'] . '</p></td> </tr>'; } mysql_free_result($sql_address); mysql_close($connect); this is more content below the sql statement and with in the variable eventinfo."; I have also tried to call an include statement of the sql inside $eventinfo but it's the same result. I understand the logic of why it will not work, I am declaring a variable and then putting variables inside but when i do that the semi colons are ending the statement early. I know there are other ways to do this besides putting it inside a variable but as of right now I am banking that this can be done some how to call the sql statement with in the variable. Any ideas?
  9. I still am trying to figure this out and have come up with a way to rig the code but it's just like an array and the fact that the information is already in the database and I can not pull it is frusturating.... <?php $cat=$_GET['cat']; $subcat=$_GET['subcat']; if ($cat == '1'){$state = "AL";} if ($cat == '2'){$state = "AK";} if ($cat == '3'){$state = "AZ";} if ($cat == '4'){$state = "AR";} if ($cat == '5'){$state = "CA";} if ($cat == '6'){$state = "CO";} if ($cat == '7'){$state = "CT";} if ($cat == '8'){$state = "DE";} if ($cat == '9'){$state = "DC";} if ($cat == '10'){$state = "FL";} echo "State is $state <br>City is $subcat<br><br>"; As you can see I can easily just call the city by $subcat, but if i do state is $cat then it returns nothing, instead i have to delcare a variable for every state above.... really weird.... Trying to use less code...alot less. Let me know if I need to provide more code. This is pulling from 2 tables with in a database, one for each drop down, category being the state and subcategory being the city....each has a auto incrementing id assigned to each city or state, hence the error i have been getting.
  10. I think I understand what you are getting at and tried something like this echo "<form method=get name=f1 action='dd-check.php'><input type='hidden' value='$noticia2[category]'>"; ////////// Starting of first drop downlist ///////// echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>"; while($noticia2 = mysql_fetch_array($quer2)) { if($noticia2['cat_id']==@$cat){echo "<option selected value='$noticia2[cat_id]'>$noticia2[category]</option>"."<BR>";} else{echo "<option value='$noticia2[cat_id]'>$noticia2[category]</option>";} } echo "</select>"; and also tried putting the value hidden else where.....If this is not what you meant let me know. Also for anyone else maybe you may see something else that could help me out as well, this is crazy.....
  11. Correct, I tried to switch out cat_id to category in the code but I am not getting it to work, I guess the coding is just not that good to manipulate ? I figured if I switched the value which is the variable that will be passed to the next page dd-check.php that it would work ..... Just cant get it to work echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>"; while($noticia2 = mysql_fetch_array($quer2)) { if($noticia2['cat_id']==@$cat){echo "<option selected value='$noticia2[cat_id]'>$noticia2[category]</option>"."<BR>";} // switched to if($noticia2['cat_id']==@$cat){echo "<option selected value='$noticia2[category]'>$noticia2[category]</option>"."<BR>";} else{echo "<option value='$noticia2[cat_id]'>$noticia2[category]</option>";} // switched to else{echo "<option value='$noticia2[category]'>$noticia2[category]</option>";} }
  12. Forgot to add the link to try so you can see what I am talking about. http://thegreatestsave.org/add/dd.php
  13. I am trying to accomplish a custom State / City drop down using a database and I am running into a small problem of pulling the wrong variable (field from the database). My end result is this State is 4 City is Jonesboro As you can see there are no states called "4", that is the cat_id assigned to the state which would be Arkansas. I tried switching around the variables a bit to try and display the state Arkansas instead of "4" but no such luck yet. Any ideas? dd.php <?php @$cat=$HTTP_GET_VARS['cat']; // Use this line or above line if register_global is off ///////// Getting the data from Mysql table for first list box////////// $quer2=mysql_query("SELECT DISTINCT category,cat_id FROM category order by category"); ///////////// End of query for first list box//////////// /////// for second drop down list we will check if category is selected else we will display all the subcategory///// if(isset($cat) and strlen($cat) > 0){ $quer=mysql_query("SELECT DISTINCT subcategory FROM subcategory where cat_id=$cat order by subcategory"); }else{$quer=mysql_query("SELECT DISTINCT subcategory FROM subcategory order by subcategory"); } ////////// end of query for second subcategory drop down list box /////////////////////////// echo "<form method=post name=f1 action='dd-check.php'>"; ////////// Starting of first drop downlist ///////// echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>"; while($noticia2 = mysql_fetch_array($quer2)) { if($noticia2['cat_id']==@$cat){echo "<option selected value='$noticia2[cat_id]'>$noticia2[category]</option>"."<BR>";} else{echo "<option value='$noticia2[cat_id]'>$noticia2[category]</option>";} } echo "</select>"; ////////////////// This will end the first drop down list /////////// ////////// Starting of second drop downlist ///////// echo "<select name='subcat'><option value=''>Select one</option>"; while($noticia = mysql_fetch_array($quer)) { echo "<option value='$noticia[subcategory]'>$noticia[subcategory]</option>"; } echo "</select>"; ////////////////// This will end the second drop down list /////////// //// Add your other form fields as needed here///// echo "<input type=submit value=Submit>"; echo "</form>"; ?> dd-check.php <?php $cat=$_POST['cat']; $subcat=$_POST['subcat']; echo "State is $cat <br>City is $subcat "; ?>
  14. Your a genious PFMABISMAD, it was the mismatch () sure enough.....when copy pasting the original file (since im reusing it) i copied to the end closing )) and left them in the middle....grrr.... Thanks so much everyone, all those before taught me a few things as well so I am very appreciative for that (shortcut for echoing a value, the debugging at the top) THANK YOU ALL!
  15. Basically i have a few types of these pages where i can just change out the field names and somewhere along the way I went astray and now the pages will not show up at all. I want to say it's as simple as a missing ; or a misspelling of syntax but for the life of me i can not find it. I will post the code but it's not fair to expect anyone to read it all since there is so much, but is there a good debugging way to find out where my problem might exist. Usually i will get t_else errors on line etc...and those are easy to diagnose, but when the page is blank...its finding a needle in the haystack. (Code below) thanks again. <html> <head> <title>Manage Coordinator Log</title> </head> <body> <?php /************************************************************************* control code for application *************************************************************************/ //submit button was pressed so call the process form function if (isset($_POST['submit'])) { process_form(); die(); }//end if //call the get_data function if (isset($_GET['id'])) { get_data(); }//endif //nothing chosen so list the dma's if ((empty($_POST))&&(empty($_GET))) { list_users(); die(); }//end if //request to add a new contact so call the show_form function if ((isset($_GET['action']))&&($_GET['action']=='add')) { show_form(); }//endif /************************************************************************* get the data for an individual contact *************************************************************************/ function get_data() { //validate the id has been passed at that it is a number if ((empty($_GET['id']))||(is_nan($_GET['id']))) { //there was a problem so list the users again list_users(); //kill the script die(); }else{ //all is ok and assign the data to a local variable $id = $_GET['id']; }//end if $sql = "select * from coordinator where id = {$id} order by KVCode;"; $result = conn($sql); if (mysql_num_rows($result)==1){ //call the form and pass it the handle to the resultset show_form($result); }else{ $msg = "No data found for selected Coordinator"; confirm($msg); //call the list users function list_users(); }//end if }//end function /************************************************************************* show the input / edit form *************************************************************************/ function show_form($handle='',$data='') { //$handle is the link to the resultset, the ='' means that the handle can be empty / null so if nothing is picked it won't blow up //set default values $KVCode = ''; $FullName = ''; $PhoneNumber = ''; $Email = ''; $AccessLevel = ''; $Commission = ''; $ReportsTo = ''; $id = ''; $value = 'Add'; //submit button value $action = 'add'; //default form action is to add a new dma/station to db //set the action based on what the user wants to do if ($handle) { //set form values for button and action $action = "edit"; $value = "Update"; //get the values from the db resultset $row = mysql_fetch_array($handle); $KVCode = $row['KVCode']; $FullName = $row['FullName']; $PhoneNumber = $row['PhoneNumber']; $Email = $row['Email']; $AccessLevel = $row['AccessLevel']; $Commission = $row['Commission']; $ReportsTo = $row['ReportsTo']; $id = $row['id']; }//end if //error handling from the processing form function if($data != '') { $elements = explode("|",$data); $KVCode = $elements[0]; $FullName = $elements[1]; $PhoneNumber = $elements[2]; $Email = $elements[3]; $AccessLevel = $elements[4]; $Commission = $elements[5]; $ReportsTo = $elements[6]; $id = $elements[7]; } ?> <body> <?php include "smsinclude.php"; echo $navigation; ?> <p style="font-size:18px; font-weight:bold;">Manage Coordinators Log</p> <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?action=<?php echo $action?>"> <table width="700" bgcolor="ffffff" cellpadding="5" cellpsacing="0" border="1" bordercolor="#000000"> <tr> <td><input type="hidden" value="<?php echo $id?>" name="id"> <table width="700" cellpadding="0" cellpsacing="0" border="0" bordercolor="#000000"> <tr> <td align="left" width="180">KV Code</td> <td width="320" align="left"><input type="text" name="KVCode" size="15" value="<?php echo $KVCode ?>"></td> <td align="left" width="200">ex) ccdhc6</td> </tr> <tr> <td align="left" width="180">Full Name</td> <td width="320" align="left"><input type="text" name="FullName" size="15" value="<?php echo $FullName ?>"></td> <td align="left" width="200">ex) David Coombs </td> </tr> <tr> <td align="left" width="180">Phone Number</td> <td width="320" align="left"><input type="text" name="PhoneNumber" size="40" value="<?php echo $PhoneNumber ?>"></td> <td align="left" width="200">ex) 765-473-3396 </td> </tr> <tr> <td align="left" width="180">Email</td> <td width="320" align="left"><input type="text" name="Email" size="40" value="<?php echo $Email ?>"></td> <td align="left" width="200">ex) dcoombs@kindervision.org </td> </tr> <tr> <td align="left" width="180">Access Level</td> <td width="320" align="left"><input type="text" name="AccessLevel" size="40" value="<?php echo $AccessLevel ?>"></td> <td align="left" width="200">ex) 1 is NC, 2 is RC, 3 is CC </td> </tr> <tr> <td align="left" width="180">Commission Percentage</td> <td width="320" align="left"><input type="text" name="Commission" size="40" value="<?php echo $Commission ?>"></td> <td align="left" width="200">ex) 25% leave out % sign </td> </tr> <tr> <td align="left" width="180">Reports To:</td> <td width="320" align="left"><input type="text" name="ReportsTo" size="40" value="<?php echo $ReportsTo ?>"></td> <td align="left" width="200">ex) Andy Mars KVRC</td> </tr> <tr> <td colspan="3"> <p align="center"><input name="submit" type="submit" value="<?php echo $value ?>"> <input name="reset" type="reset" value="Clear Form"></p> </td> </tr> </table> </td> </tr> </table><br /> </form> <?php echo $navigation2; ?> <? }//end function /************************************************************************* list all the DMA/Stations in the db *************************************************************************/ function list_users() { $y = 0; //counter $sql = "select * from coordinator order by KVCode;"; $result = conn($sql); include "smsinclude.php"; echo "<table width=\"700\" cellpadding=\"0\" cellspacing=\"0\"> <tr><td colspan=\"2\" style=\"font-size:18px; font-weight:bold;\">Manage Coordinator Log</td></tr> <tr> <td valign=\"top\"><br><a href='".$_SERVER['PHP_SELF']."?action=add'>Add a new Coordinator</a></td> <td valign=\"top\"><br>$navigation</td> </tr> </table> <table width=\"1060\" cellpadding=\"5\" cellspacing=\"0\"> <tr> <td width=\"80\"><b><u>KV Code</u></b></td> <td width=\"150\"><b><u>Full Name</u></b></td> <td width=\"150\"><b><u>Phone Number</u></b></td> <td width=\"150\"><b><u>Email</u></b></td> <td width=\"150\"><b><u>Access Level</u></b></td> <td width=\"150\"><b><u>Commission Percentage</u></b></td> <td width=\"150\"><b><u>Reports To</u></b></td> <td width=\"80\"><b><u>Delete</u></b></td></tr>"; if (mysql_num_rows($result)){ //show a list of kids with name as a link to the prepopulated form with their data in it while($rows = mysql_fetch_array($result)){ //change row background color (($y % 2) == 0) ? $bgcolor = "#F8F7F2" : $bgcolor=" #FFFFFF"; //build strings to make life easier $KVCode = $rows['KVCode']; $FullName = $rows['FullName']; $PhoneNumber = $rows['PhoneNumber']; $Email = $rows['Email']; $AccessLevel = $rows['AccessLevel']; $Commission = $rows['Commission']; $ReportsTo = $rows['ReportsTo']; $id = $rows['id']; $field_data = "coordinator"; //convert status to readable string from 1 or 0 ($status == 0) ? $status = "Available to contact" : $status = "Do not contact at present."; //echo out the row echo "<tr style='background-color:$bgcolor;'> <td valign=\"top\" width=\"80\" height=\"30\" valign=\"middle\"><a href='".$_SERVER['PHP_SELF']."?id=$id'>$KVCode</a></td> <td valign=\"top\" height=\"30\" valign=\"middle\">$FullName</td> <td valign=\"top\" height=\"30\" valign=\"middle\">$PhoneNumber</td> <td valign=\"top\" height=\"30\" valign=\"middle\">$Email</td> <td valign=\"top\" height=\"30\" valign=\"middle\">$AccessLevel</td> <td valign=\"top\" height=\"30\" valign=\"middle\">$Commission</td> <td valign=\"top\" height=\"30\" valign=\"middle\">$ReportsTo</td> <td width=\"80\" valign=\"top\" height=\"30\" valign=\"middle\"><a href='delete_record.php?id=$id&field_data=$field_data'>Delete</a></td><tr>"; $y++; //increment the counter }//end while echo "</table><br>$navigation2 <br><br>If you wish to print this page you must use Landscape Printing for best results"; }else{ //handle no results echo "<tr><td colspan='9' align='center'><b>No data found.</b></td></tr>"; }//endif } /************************************************************************* add / update the contact's data *************************************************************************/ function process_form() { $KVCode = ''; $FullName = ''; $PhoneNumber = ''; $Email = ''; $AccessLevel = ''; $Commission = ''; $ReportsTo = ''; $id = ''; $action = ''; $status = 0; //default value $KVCode = @$_POST['KVCode']; $FullName = @$_POST['FullName']; $PhoneNumber = @$_POST['PhoneNumber']; $Email = @$_POST['Email']; $AccessLevel = @$_POST['AccessLevel']; $Commission = @$_POST['Commission']; $ReportsTo = @$_POST['ReportsTo']; $id = @$_POST['id']; $action = @$_GET['action']; $status = @$_POST['status']; //if no status is set, defaults to 0 (allow contact) if ($status == ''){$status = 0; } if (($KVCode=='')||($FullName=='')||($PhoneNumber=='')||($Email=='')||($AccessLevel==''))||($Commission=='')||($ReportsTo=='')) { $msg = "Some data from the form was forgotten. Please fill in the entire form."; confirm($msg); $data = "$KVCode|$FullName|$PhoneNumber|$Email|$AccessLevel|$Commission|$ReportsTo|$id"; show_form('',$data); die(); }//end if //You could add some validation of the data ( I recommend it and its a great way to get your feet wet with php ) if ($action == "add") { $sql = "insert into coordinator (KVCode, FullName, PhoneNumber, Email, AccessLevel, Commission, ReportsTo) values('{$KVCode}','{$FullName}','{$PhoneNumber}','{$Email}','{$AccessLevel}','{$Commission}','{$ReportsTo}');"; $msg = "Record successfully added"; }elseif($action=="edit"){ $sql = "update coordinator set KVCode = '{$KVCode}', FullName = '{$FullName}', PhoneNumber = '{$PhoneNumber}', Email = '{$Email}', AccessLevel = '{$AccessLevel}', Commission = '{$Commission}', ReportsTo = '{$ReportsTo}' where id = {$id};"; $msg = "Record successfully updated"; } $result = conn($sql); if (mysql_errno()==0) { confirm($msg); list_users(); }else{ $msg = "There was a problem adding the user to the database. Error is:".mysql_error(); confirm($mag); }//end if } /************************************************************************* db connection function *************************************************************************/ function conn($sql) { $host = "localhost"; $user = "root"; $pass = "root"; $db = "dreamteam_db"; //echo "commnecing connection to local db<br>"; if (!($conn=mysql_connect($host, $user, $pass))) { printf("error connecting to DB by user = $user and pwd=$pass"); exit; } $db3=mysql_select_db($db,$conn) or die("Unable to connect to local database"); $result = mysql_query($sql) or die ("Can't run query because ". mysql_error()); return $result; }//end function /************************************************************************* alert box popup confimation message function *************************************************************************/ function confirm($msg) { echo "<script langauge=\"javascript\">alert(\"".$msg."\");</script>"; }//end function ?>
×
×
  • 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.