Jump to content

jesushax

Members
  • Posts

    498
  • Joined

  • Last visited

    Never

Everything posted by jesushax

  1. well heres the actual code, for what im using it for EDIT: no sorry its displaying 1 blank <li>now <?php $TradesField = $row["Sect1_6"]; $trades = array_map('trim',explode(',',rtrim(',',$TradesField))); $st = 0; $len = 3; $part = array_slice($trades,$st,$len); while (!empty($part)) { echo '<ul><li>' . implode('</li><li>',$part) . "</li></ul>\n"; $st += $len; $part = array_slice($trades,$st,$len); } ?>
  2. i used both, both of them display <ul><li>Architects / Designers</li><li></li></ul> the field is trades and contains this data Architects / Designers, there is not trailing spaces either what you think it is?
  3. GREAT thanks what if there is less than 3 <li>? cos the particular dog field in looking at only has 1 but im getting <li>Doggy1<li><li> Thanks
  4. hi all what im trying to do is say $DogField = "german shepard,shitzu,husky, doberman, Lindsey Lohan"; how would i get that variable into <ul> <li>German Shepard</li> <li>Shitzu</li> <li>Husky</li> </ul> <ul> <li>Doberman</li> <li>Lindesy Lohan</li> </ul> so that every three <li>s a new list is created my idea was something like str_replace(",","</li><li>",$Dogfield);
  5. yes i tested it regardless of dreamweavers non colouring, im not stupid lol ah yes it did work i had my functions.php include lower then the text i wanted to run the addSpaces function on moved it to the top and its all good now thankyou very much for your time
  6. sorry didnt work again
  7. that didnt work :| in dreamweaver PREG_SPLIT_NO_EMPTY+PREG_SPLIT_DELIM_CAPTURE); didnt show up as an colour could something be wrong there?
  8. hi say i have a value "JohnSmith" would it e possible to change with code to "John Smith" there needs to be no sapces in teh db field name as its used for other scripts but i would like to display it on pages with a space THanks
  9. what you mean escaping post vars? thanks
  10. hi all, this is my error checking system for registrations it grabs all the emails and all the postcodes from the db then compares the domains and the postcodes to see if any of them match to what has just been inputted is there a better way to do the below? list($name, $domain) = explode("@",$_POST["Sect1_6"]); $postcode = trim(strtoupper($_POST["Sect1_7d"])); $sql = mysql_query("SELECT `Sect1_6`,`Sect1_7d`,`CompanyID` FROM tblDirectory2") or die(mysql_error()); while($row = mysql_fetch_array($sql)) { list($namecheck, $domaincheck) = explode("@", $row["Sect1_6"]); $postcodecheck = trim(strtoupper($row["Sect1_7d"])); if ($domaincheck == $domain ) { header("Location: /new_directory/completed.php?ID=".$row["CompanyID"]); exit();} if ($postcodecheck == $postcode) { header("Location: /new_directory/completed.php?ID=".$row["CompanyID"]); exit();} }
  11. what im tryign to do is say table 1 has the number 35 in the DOG Field and only has one row then in table 2 has many numbers from 1-100 in multiple rows but still in the CAT field how would i be able to use dog field to search and find an equal in the CAT field so table 1 Column DOG Row 35 table 2 Column CAT Row 12 Row 29 Row 87 Row 32 Row 13 Row 35 i want to compare whats in table 1 DOG to all the Values in table 2 CAT then if one matches dispay some text Thanks for any help
  12. i tried the code suggested and the redirects still dont work :| heres the code now case "part1"; $email = $_POST["Sect1_6"]; $error = mysql_query("SELECT `Sect1_6`,`Sect1_7d`,`CompanyID` FROM tblDirectory2 WHERE `Sect1_6`='$email'") or die(mysql_error()); $errorID = mysql_fetch_array($error,MYSQL_NUM); // This gives you a numeric indexed array $emailcheck = $errorID[0]["Sect1_6"]; // notice the 0 list($name, $domain) = explode("@", $email); list($name, $domaincheck) = explode("@", $emailcheck); $postcode = strtoupper($_POST["Sect1_7d"]); $postcodecheck = strtoupper($errorID[0]["Sect1_7d"]); // Notice the 0 if ($domaincheck == $domain || $postcodecheck == $postcode) { header("Location: /new_directory/completed.php?ID=".$errorID["CompanyID"].""); exit(); } $posts = $_POST; unset($posts['password']); unset($posts['password2']); for($i=1; $i<=21; $i++) { unset($posts['T'.$i]); } $SQL = "INSERT INTO tblDirectory2 ("; foreach($posts as $key=>$value){ $SQL .= "`$key`, "; } $SQL .="`Sect1_2`,`password`) VALUES ("; foreach($posts as $key=>$value){ $SQL .= "'$value', "; } $const = "T" ; for ($i=1;$i<=21;$i++){ $var = trim($_POST[$const.$i]) ; if(!empty($var)) { $trades .= $_POST[$const.$i] . "," ; } } $SQL .="'".mysql_escape_string($trades)."','".md5($_POST["password"])."')"; echo $SQL; //mysql_query($SQL) or die (mysql_error()); $Company = mysql_query("SELECT `CompanyID` FROM tblDirectory2 WHERE `Sect1_6`='$email'") or die(mysql_error()); while ($ID = mysql_fetch_array($Company)) { header("Location: /new_directory/regform_sect2.php?ID=".$ID["CompanyID"].""); exit(); } break;
  13. hi all below is my code ive commented out the mysql becuase i dont want an more info being inserted into my db for now but i tried inputting the same postcode as the one record that already has been added to the db and i just get taken to register.php?action=part1 and the sql statement the if statement to check the domain and the postcode isnt working as i see it and the lower if statement to referr to part 2 isnt working either becuase it should been executed if the first if statement didnt work? also for the postcode check if already got it turning to uppercase is theere a way i can remove all spaces too? thanks $email = $_POST["Sect1_6"]; $error = mysql_query("SELECT `Sect1_6`,`Sect1_7d`,`CompanyID` FROM tblDirectory2 WHERE `Sect1_6`='$email'") or die(mysql_error()); $errorID = mysql_fetch_array($error); $emailcheck = $errorID["Sect1_6"]; list($name, $domain) = explode("@", $email); list($name, $domaincheck) = explode("@", $emailcheck); $postcode = strtoupper($_POST["Sect1_7d"]); $postcodecheck = strtoupper($errorID["Sect1_7d"]); if ($domaincheck == $domain || $postcodecheck == $postcode) { header("Location: /new_directory/completed.php?ID=".$errorID["CompanyID"].""); exit(); } $posts = $_POST; unset($posts['password']); unset($posts['password2']); for($i=1; $i<=21; $i++) { unset($posts['T'.$i]); } $SQL = "INSERT INTO tblDirectory2 ("; foreach($posts as $key=>$value){ $SQL .= "`$key`, "; } $SQL .="`Sect1_2`,`password`) VALUES ("; foreach($posts as $key=>$value){ $SQL .= "'$value', "; } $const = "T" ; for ($i=1;$i<=21;$i++){ $var = trim($_POST[$const.$i]) ; if(!empty($var)) { $trades .= $_POST[$const.$i] . "," ; } } $SQL .="'".mysql_escape_string($trades)."','".md5($_POST["password"])."')"; echo $SQL; //mysql_query($SQL) or die (mysql_error()); $Company = mysql_query("SELECT `CompanyID` FROM tblDirectory2 WHERE `Sect1_6`='$email'") or die(mysql_error()); while ($ID = mysql_fetch_array($Company)) { header("Location: /new_directory/regform_sect2.php?ID=".$ID["CompanyID"].""); exit(); }
  14. hi all, my code is below ive commented out the mysql for now, cos i dont want it adding to the db but whats happening is if i comment out the line in red the redirect in orange works but if i have the redirect in red on, then it cancels out the redirect in orange if you get me? can anyone tell me why? Thanks $email = $_POST["Sect1_6"]; list($name, $domain) = explode("@", $email); $error = mysql_query("SELECT `Sect1_6`,`CompanyID` FROM tblDirectory2 WHERE `Sect1_6`='$email'") or die(mysql_error()); $errorID = mysql_fetch_array($error); $emailcheck = $errorID["Sect1_6"]; list($name, $domaincheck) = explode("@", $emailcheck); if ($domaincheck == $domain) { [color=orange]header("Location: /new_directory/completed.php?ID=".$errorID["CompanyID"]."");[/color] } $posts = $_POST; unset($posts['password']); unset($posts['password2']); for($i=1; $i<=21; $i++) { unset($posts['T'.$i]); } $SQL = "INSERT INTO tblDirectory2 ("; foreach($posts as $key=>$value){ $SQL .= "`$key`, "; } $SQL .="`Sect1_2`,`password`) VALUES ("; foreach($posts as $key=>$value){ $SQL .= "'$value', "; } $const = "T" ; for ($i=1;$i<=21;$i++){ $var = trim($_POST[$const.$i]) ; if(!empty($var)) { $trades .= $_POST[$const.$i] . "," ; } } $SQL .="'".mysql_escape_string($trades)."','".md5($_POST["password"])."')"; //echo $SQL; //mysql_query($SQL) or die (mysql_error()); $Company = mysql_query("SELECT `CompanyID` FROM tblDirectory2 WHERE `Sect1_6`='$email'") or die(mysql_error()); while ($ID = mysql_fetch_array($Company)) { [color=red]header("Location: /new_directory/regform_sect2.php?ID=".$ID["CompanyID"]."");[/color] }
  15. hi all as the title suggests how can i get everything after an @symbol into a variable and remove any spaces someone may have put after domain, also using mysql_real_escape_string does that remove any trailing spaces before inputting them into the db? Thanks
  16. what does the ` do?
  17. hi all, the top line is the echoed sql and the second line is the error from the sql can i have dashes (-) in a statment? is that what the error is saying? Thanks INSERT INTO tblDirectory2 (Sect1-6, Sect1-1, Sect1-3, Sect1-4, Sect1-5, Sect1-7a, Sect1-7b, Sect1-7c, Sect1-7d, Sect1-8, Sect8-1, Sect1-2) VALUES ('', 'Limited Company', '', '', '', '', '', '', '', '', '0-5', '') You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-6, Sect1-1, Sect1-3, Sect1-4, Sect1-5, Sect1-7a, Sect1-7b, Sect1-7c, Sect1-7d, ' at line 1
  18. hi all im trying to get the fields T1 - T21 into an variable seperated by commas i did the below orginally, but then i get a load spare commas randomly placed for posts that are empty any ideas? Thanks $trades = $_POST["T1"].","; $trades .= $_POST["T2"].","; $trades .= $_POST["T3"].","; $trades .= $_POST["T4"].","; $trades .= $_POST["T5"].","; $trades .= $_POST["T6"].","; $trades .= $_POST["T7"].","; $trades .= $_POST["T8"].","; $trades .= $_POST["T9"].","; $trades .= $_POST["T10"].","; $trades .= $_POST["T11"].","; $trades .= $_POST["T12"].","; $trades .= $_POST["T13"].","; $trades .= $_POST["T14"].","; $trades .= $_POST["T15"].","; $trades .= $_POST["T16"].","; $trades .= $_POST["T17"].","; $trades .= $_POST["T18"].","; $trades .= $_POST["T19"].","; $trades .= $_POST["T20"].","; $trades .= $_POST["T21"];
  19. found answer here http://tech.petegraham.co.uk/2007/03/22/php-remove-values-from-array/
  20. can you show me? im not that familiar with using arrays yet thanks
  21. hi all, below is my code what i want to be able to do is to exclude certain fields from the form being put in the below array, is there a way to do this? Thanks foreach($_POST as $key=>$value) $SQL = "INSERT INTO tblDirectory2 ("; foreach($_POST as $key=>$value){ $SQL .= "$key, "; } $SQL = rtrim($SQL,', '); $SQL .=") VALUES ("; foreach($_POST as $key=>$value){ $SQL .= "'$value', "; } $SQL = rtrim($SQL,', '); $SQL .=")";
  22. whoops :| such an idiot mistake :| its the my keyboard that makes me do line breaks the wrong way my / and \ are next to eachother and i sometimes press wrong one and i just copied and pasted the wrong one lots! lol thanks for the hlep any guys
  23. hi all, below is my code, which just returns a blank page, the sql is working becuase i can remove everything below $i = 0; and get results from echoing the sql thanks <?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/connection.php'); $sql = mysql_query("SELECT * FROM tblLatest ORDER BY ArticleDateAdded DESC LIMIT 3") or die(mysql_error()); $i = 0; while($article = mysql_fetch_array($sql)) { ++$i; if ($i % 2 == 0) // Here are your even records { echo'<div class="front-box-middle">'."/n" echo'<h2>'.$article["ArticleTitle"].'</h2>'."/n" echo'<div><img src="/latest/uploads/thumbs/'.$article["ArticleImage"].'" alt="'.$article["ArticleImage"].'" /></div>'."/n" echo'<p>'.$article["ArticleBrief"].'</p>'."/n" echo'</div>'."/n" } else // Here are your odd records { echo'<div class="front-box">'."/n" echo'<h2>'.$article["ArticleTitle"].'</h2>'."/n" echo'<div><img src="/latest/uploads/thumbs/'.$article["ArticleImage"].'" alt="'.$article["ArticleImage"].'" /></div>'."/n" echo'<p>'.$article["ArticleBrief"].'</p>'."/n" echo'</div>'."/n" } } ?>
×
×
  • 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.