
brady123
Members-
Posts
39 -
Joined
-
Last visited
Never
Everything posted by brady123
-
For all of you RegEx experts...here is my code: $str=preg_replace("/\[word=(.)(.*)\](.*)\[\/word\]/Usi", "<a href=\"http://www.accountingconcern.com/accounting-dictionary/".strtoupper('\\1')."/\\1\\2/ \">\\3</a>", $str); Basically it is taking [word=debit]Debit[/word] and making it link. The problem is, where I have the first \\1, I need that letter capitalized - not working. I'm not getting an error, it is just not capitalizing that letter. Any ideas? Thank you!
-
Can anyone see what is wrong with this code?
brady123 replied to Bentley4's topic in PHP Coding Help
Yeah, I was typing as you posted I wasn't aware of the tag, but I'll start using it! -
Can anyone see what is wrong with this code?
brady123 replied to Bentley4's topic in PHP Coding Help
First, is $answer an array? I think the $end problem is that you are not closing out your second-to-last IF statement. Also, you don't need an else statement if nothing is being done. Also, the while statement looks a little funky - see changes below. if(isSet($_GET['answer'])) { $answ = $_GET['answer']; $nextanswer=$answ+1; } $counter2 = 1; while ($counter2 <= $answ) { echo $Answer[$counter2]."<br>"; $counter2++; } if($nextansw>0) { if(isset($Answer[$nextanswer])) { echo "<a href=\"/Code-sandbox.php?sid=".$name."&answer=".$nextanswer."\">next</a>"; } else { echo "End of questions<br>"; } } -
Wow, HUGE thank you to everyone for your help, especially mjdamato for taking the time to completely write the script! I really, really appreciate your help! It's working like a charm, and makes sense so that I can customize it. If I end up expanding it to use OR operators and other options, based on field type, I'll be sure to post on the forum for others to use. Thanks again!
-
First off, thank you phpJoeMo for the help! It worked, with the little snag that mjdamato brought up. I'm not totally sure that I understand what you're getting at, mjdamato. You see my code there, are you suggesting something like assign a numeric value, based on the $x counter in my "for" loop, then once the data has been submitted, check each number (based on $x), and see if the checkbox has been checked. Off of that, I would grab the information to the corresponding operator drop-down list and input box? Meaning that the names would be something to the ffect of "operator0, operator 1, etc." and "input1, input2, etc." Thus, once I find that checkbox1 has been checked, grab the information from operator1 and input1? I don't know if my reasoning makes sense here. To do this, would I just rename my input from name='column[]' to name='column[$x]' ? I could be way off here, but the help is much appreciated!
-
I'm not sure if the title explains it very well, but here is an image of it. I am trying to figure out how to access the option selected (equal, not equal, etc.), along with its input box, for each column (the checkboxes on the right) selected. The purpose of this is to allow a non-programming administrator user to create a custom query to access information. I can find out which checkboxes are selected no problem, but finding the accompanying drop-down option and input box is difficult for me. How do I do this? If you have a suggestion on how to change it, I'm very open. Thank you in advance! if(!isset($_POST['submit'])) { echo " <form method='post'> <table> <tr> <td valign='top'>SELECT</td> <td valign='top'> <table>"; // LIST ALL COLUMNS IN A TABLE $result = mysql_query("SELECT * FROM table_name") or die(mysql_error()); $rowcount=mysql_num_rows($result); $y=mysql_num_fields($result); for ($x=0; $x<$y; $x++) { echo " <tr> <td> <input type='checkbox' name='fields[]' value='".mysql_field_name($result, $x)."'>".mysql_field_name($result, $x)." </td> </tr>"; } echo " </table> </td> <td valign='top'>FROM allocations</td> <td valign='top'>WHERE</td> <td> <table>"; // LIST ALL COLUMNS IN A TABLE $result = mysql_query("SELECT * FROM table_name") or die(mysql_error()); $rowcount=mysql_num_rows($result); $y=mysql_num_fields($result); for ($x=0; $x<$y; $x++) { echo " <tr> <td> <input type='checkbox' name='column[]' value='".mysql_field_name($result, $x)."'>".mysql_field_name($result, $x)." </td> <td> <select name='operator[]'> <option value='='>equals</option> <option value='<>'>does not equal</option> <option value='>'>greater than</option> <option value='<'>less than</option> <option value='>='>greater than or equal to</option> <option value='<='>less than or equal to</option> <option value='LIKE'>is like</option> </select> </td> <td><input type='text' name='criteria[]'></td> </tr>"; } echo " </table> </td> <td valign='top'><input type='submit' value='Process Query' name='submit' class='submit'></td> </tr> </table> </form>"; } else { echo "<b>Fields to edit:</b> "; foreach ($_POST['fields'] as $fields) { echo $fields,", "; } echo "<br><br>"; echo "<b>Columns to query:</b> "; foreach ($_POST['column'] as $columns) { echo $columns," HERE IS THE SPOT, "; } }
-
I'm trying that, but it's not working. For example, I have this at the beginning, the very first thing, of every page: <?php include ("/headerinfo.php"); ?> The page continues from there. In that 'headerinfo' include file, I have on the very first line: <?php session_start(); ?> I imagine that's what I need to do to have sessions started on every page, but for some reason, pages aren't recognizing it. Any thoughts/tips?
-
I have an include file that is included in every page of my website. I'm using sessions and trying to streamline code. The very first line of any page is my include file, and the very first thing in that file is: <?php session_start(); ?> The page doesn't register that a session was started. Do I have to have session_start() on every single page? Or is there a way to have it in my include file so it is automatically on every page for me? Thank you!
-
The problem with strip tags is that I WANT to keep my html/php tags in the output. It's just that the <strong> tag is overriding the font-weight:normal; style tag, even though the font-weight:normal tag comes after the <strong> tag. Does that make sense?
-
Hmm, that still doesn't quite get what I'm going for. Perhaps if I explained myself a little better (by the way, thank you SO much for the help - I really appreciate it). I'm running a query in MySQL to output questions and answers. <?php $i=0; while ($i < $num and $i < 5) { echo "<a href='/accounting-questions/index.php?qid=" . $qid . "'>$question</a><br>"; echo "<p>$answer</p>"; $i++; } ?> In my MySQL database, the $answer field contains HTML (to format the answer how I want it to be). When I use the substring function to cut off $answer after 35 words, I am sometimes left in the middle of a bolded statement (for example: "you <strong>need to" where it cuts off before I include </strong> to end the statement). THEN, on my next loop, the $question and $answer variables are bolded because that <strong> tag never was closed, since the substring only grabbed the first 35 words - before the tag was closed. In my <p> tag, on my style sheet, I have font-weight:normal; This seems to revert the text back to normal in Chrome and Explorer, but not Firefox. Firefox keeps the <strong> attribute from the first instance. Does this make sense? I'm still fairly new to PHP and MySQL databases, so perhaps there is a better way. Thanks!
-
First, thanks for the tip with <strong>. Second, the reason it's formatted like that is because the <b> tag came out of a MySQL entry. I'm using a SUBSTRING tag to cut off what is output after x amount of words. It happens to cut off after the <b>, and therefore leaves the rest of the page bold.
-
If I have the following code: <b>Hello there<p>sir.</p> and in my CSS the "p" tag has font-weight:normal; the "sir" turns out bold. It seems to function correctly (making "sir" normal weight in Chrome in Explorer, but not Firefox. Any ideas/fixes?
-
Loop in two columns, the second starting at row XXX
brady123 replied to brady123's topic in PHP Coding Help
Ah, ok. Don't know how I missed that. It's too bad I'll have to use a table Thanks for your quick reply and help! -
I'm new here and have tried to find the answer before I started a new thread. Sorry if this has been addressed! I'm running a while loop to generate a dictionary that contains definitions in a MySQL database. It's working fine, but I'd like to have the words begin a second column on the page if my $num variable (that holds the returned amount of rows of the query) reaches 31 or more. For example, I'd like the first 30 words listed in one column, then words 31-60 in another column, and so on. How can this be done? Can you have a new query list words beginning at row 31 of a generated query? Thank you for your help!