A JM
Members-
Posts
249 -
Joined
-
Last visited
Everything posted by A JM
-
Many thanks. A JM,
-
How do I write a SELECT query using a variable echoed from another query, <?php echo $row_rstreviewclaims['num']; ?> I tried the following with no luck - I can't get the syntax correct... $query_rstcomments = "SELECT comment FROM comments WHERE num = " <?php $row_rstreviewclaims['num']; ?>; Any help would be appreciated. Thanks. A JM,
-
Not sure why the backslash didn't show up but that is what I'm currently using? escaping I'm guessing is my problem...? <?php $query_rstcomments = "SELECT comment FROM comments; $rstcomments = mysql_query($query_rstcomments, $dbconn) or die(mysql_error()); while ($rec=mysql_fetch_assoc($rstcomments)){ $comment = $comment . '\n' . $rec['comment']; } ?>
-
I'm trying to add breaks to my $comment line but its not working as I anticpiated, can someone help me out with this? It just runs on with breaking after each item in the query...? <?php $query_rstcomments = "SELECT comment FROM comments; $rstcomments = mysql_query($query_rstcomments, $dbconn) or die(mysql_error()); while ($rec=mysql_fetch_assoc($rstcomments)){ $comment = $comment . "\n" . $rec['comment']; } ?> <textarea cols="40" wrap="virtual" disabled="disabled"><?php echo $comment; ?></textarea> Thanks. A JM,
-
[SOLVED] Looking for a way to present database information?
A JM replied to A JM's topic in PHP Coding Help
That might be exactly what I'm looking for - I don't need the user to be able to add any information, I just want to display whats in the DB field in it. Thanks. -
[SOLVED] Looking for a way to present database information?
A JM replied to A JM's topic in PHP Coding Help
yes, sorry I must not have been very clear. I don't want access to the DB only to display the record information in a list box on my form that the end user can read through. My concern is the amount of information to be displayed my be large and I don't know if a textarea will be appropriate for my needs. Thanks. -
I'm looking for a way to present records in a field of my database - kind of like a chat box where the comments are seperated by user but I want to use recordID's instead to seperate the comments. I'd like the user to be able to scroll through the list of a "comment" field of my DB. Does anyone have any ideas for creating such a thing, is there already something available for me to use? Any help or suggestions would be appreciated. Thanks. A JM,
-
I have a table with userid set as a unique field in my DB since I don't want duplicates. Before my user submits the form for adding a new user how can I validate that the userid doesn't exist and give the user some feedback? A JM,
-
Sweet! many thanks... A JM,
-
I see that I was adding <?php tags where they weren't needed... no errors on loading the page but no img either? any thoughts? Thanks,
-
Should this be implemented in HTML like so?
-
Is there a way to disable a image link on my page if the resultset from a Mysql query returns zero rows? Maybe there is a better way to do this instead of testing the resultset is equal to zero, any other ideas or suggestions? Thanks, A JM,
-
Thanks for all the input.
-
Is there a simple function for converting a date in "m/d/y" format to mysql datetime format of "y-m-d"? A JM,
-
Is there a reason this can't be done on a single line? Thanks,
-
I'm still trying to get this to work and having problems. $selectBox = "<select id='querytype' name = 'querytype' onchange='loadWheres();'><option>Select Query Type</option>"; $selectBox = $selectBox."<option value=number<?php if(". $querytype ." == number) {echo selected=selected; }?>Number</option>"; $selectBox = $selectBox."</select>"; From the source of the page. <select id='querytype' name = 'querytype' onchange='loadWheres();'><option>Select Query Type</option><option value=number <?php if(number == number) {echo selected=selected; }?>Number</option></select> Since the php is showing on the page I know I have the syntax wrong... Any help would be appreciated.
-
I believe this is correct but I can't get the syntax correct, any help? $selectBox = $selectBox.'<option value=number. <?php if($querytype == number) {echo "selected=selected"; }?>>Number</option>';
-
Like? $selectBox = $selectBox.'<option value='number' <?php if ($selectedItem == 'number') { echo ' selected="selected" '; }?>>Number</option>';
-
If I have a listbox like so and I have a variable with the value of the item that I want to have selected how can this be done? $selectedItem = $_GET['querytype']; $selectBox = "<select id='querytype' name='querytype' onchange='loadWheres();'><option>Select Query Type</option>"; $selectBox = $selectBox.'<option value="number">Number</option>'; $selectBox = $selectBox.'<option value="name">Name</option>'; $selectBox = $selectBox.'<option value="address">Address</option>'; $selectBox = $selectBox.'<option value="state">State</option>'; $selectBox = $selectBox."</select>"; <script type="text/javascript"> function loadWheres() { var d = document.getElementById('querytype'); var value = d.value; document.location = 'filtered_qrys.php?querytype=' + escape(value); } </script>
-
Neil, Since I suck at joining tables and the like can you explain a little why a left join seems to have worked? Thanks for all your help. A JM,
-
This works perfectly with one exception - you knew it was coming... sorry SELECT e.user_id, e.home_id, u.user_name AS user1, h.user_name AS user2 FROM EntryTable e INNER JOIN UserTable u ON(e.user_id = u.user_id) INNER JOIN UserTable h ON(e.home_id = h.user_id) By default the the EntryTable has both fields user_id and home_id set to zero(0) and there is no zero(0) in the UserTable so unless both fields are populated I get nothing, anyway you can think of around this? A JM,
-
On the second join did you mean to join the h table instead of the u table or does it matter what table is referenced? ...INNER JOIN UserTable u ON(e.user_id = u.user_id) INNER JOIN UserTable h ON(e.home_id = h.user_id) Thanks. A JM,
-
I still think this has a problem in that as long as the user_id and home_id are the same user it will work but if the user_id and the home_id are different users it wouldn't, does that make sense? With a slight modification to the UserTable - that's my fault I misled you. UserTable user_id user_name home_descr ... EntryTable item_number rack_position user_id 'from UserTable user_id home_id 'from UserTable user_id ... For instance from the EntryTable the user_id and home_id can be different. Ultimately I should be able to pull any field from the UserTable given either the user_id or the home_id from the EntryTable. user_id=1 home_id=1 should equate to: user_name=fred_flinstone user_name=fred_flinstone user_id=1 home_id=2 should equate to: user_name=fred_flinstone user_name=barney_rubble user_id=2 home_id=2 should equate to: user_name=wilma_flinstone user_name=barney_rubble user_id=3 home_id=5 should equate to: user_name=bam_bam user_name=pebbles
-
This works perfectly for the user_id but not for the home_id. SELECT u.user_name, e.* FROM UserTable u INNER JOIN EntryTable e ON (u.user_id = e.user_id) I think I also need a query like this incorporated into the first query - is that possible or am I thinking about this incorectly? SELECT u.home_descr, e.* FROM UserTable u INNER JOIN EntryTable e ON (u.home_id = e.home_id) A JM,
-
I have 2 tables that I want to pull some results from. The fields from the 2 tables that I'm mostly concerned with are as follows. UserTable user_id home_id user_name home_descr ... EntryTable item_number rack_position user_id home_id ... Essentially I want to pull the user_name and home_descr from the UserTable with a SELECT query that pulls from the EntryTable sort of like below. I'm just terrible at joining tables together and could use some help. SELECT item_number, rack_position, user_name, home_descr FROM EntryTable