Jim R
Members-
Posts
988 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Jim R
-
Any help on what the IF statement should look like? What you have above isn't registering well in my head right now. Not sure about 'rows' and I'm not using ID's. Sometimes I have mental blocks when it comes to coding.
-
Here is what I have so far, realizing I still need the IF and ELSEIF statements, as well as the UPDATE. <?php $con = mysql_connect("localhost","db_name","db_password"); if (!$con) { die('Could not connect: ' . mysql_error()); } $nameFirst=$_POST['nameFirst']; $nameLast=$_POST['nameLast']; $school=$_POST['school']; mysql_select_db("db_table_name", $con); $result = mysql_query( "SELECT * FROM fallLeague10 WHERE nameFirst='$nameFirst' AND nameLast='$nameLast' AND school='$school' "); // IF statement? //UPDATE code //ELSEIF $sql="INSERT INTO fallLeague09reg(nameFirst,nameLast,email,addressHome,stateHome,zipHome,phoneHome,phoneMobile,school,grade,coachSchool,feet,inches) VALUES ('$_POST[nameFirst]','$_POST[nameLast]','$_POST[email]','$_POST[addressHome]','$_POST[stateHome]','$_POST[zipHome]','$_POST[phoneHome]','$_POST[phoneMobile]','$_POST[school]','$_POST[grade]','$_POST[coachSchool]','$_POST[feet]','$_POST[inches]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } header( 'Location: /fall-league/payment' ); mysql_close($con) ?>
-
So instead of SELECT id FROM users WHERE name='Neil' It should be???? ....WHERE nameFirst='$_POST['nameFirst']' && nameLast='$_POST['nameLast']' && school=$_POST['school'] I don't get how using the ID helps me, and I'm trying to match information from form not another table.
-
After looking at this a little more, I would rather not use Replace. It will increase the number of rows I have with every entry. I like to keep track of how many individuals are actually in my database, so I can compare from year to year. If it gets right down to it, I could use it, but I'd prefer not. Neil, I think I can figure out the query syntax if I understand more of what you're talking about. If I SELECT to see if the record already exists, how do I create conditions? Are we talking about IF statements or WHERE statements within the query? My query would look like: SELECT * from TableA UPDATE SET (column information) WHERE TableA = $_POST['value']
-
@BH, I'll look more into that for sure. @Neil, do I just run a Select * or just the fields I want to check (nameFirst, nameLast, school)? I guess this is the direction that confuses me.
-
I'm pulling information from a form that INSERTS into my database. I think I have the UPDATE syntax down for when a User enters information that is already in the database. UPDATE....WHERE....FormA = ColumnA...AND...FormB = ColumnB. What I need is help with is if it's not updating an existing User's information, getting it to insert a new row. Do I set it up the same way as the update, just with INSERT...WHERE...FormA == ColumnA AND FormB == ColumnB?
-
Enter new information into an established database
Jim R replied to Jim R's topic in PHP Coding Help
(I was typing my response as you were typing your second one, but at least I'm following your logic.) Is there MySQL/PHP command I should use, or am I basically using IF...THEN statements? -
Enter new information into an established database
Jim R replied to Jim R's topic in PHP Coding Help
Knowing the players very well, there won't be an instance where there is identical player names at different schools, let alone the same schools, so I would be safe there. From there, what you're saying is I'm checking the data already there, and if it finds identical information, I need to UPDATE, and if I don't, I need to INSERT? -
Enter new information into an established database
Jim R replied to Jim R's topic in PHP Coding Help
I haven't tried any code for this specifically, mostly because I'm not sure where to start. Here is the code I use for the form I have set up now, which enters all information into a second database. I'd like to check the database I have set up for invitees, and if there is already a record of that player, update his entry with the additional information asked for in the form. <form id="entryFall" action="/form/dbenter.php" method="post"> <table border="0" width="500"> <tbody> <tr> <td colspan="4"> <div><strong><span style="font-size: x-small;">Fall Varsity League</span></strong></div></td> </tr> <tr> <td colspan="4"> <div style="text-align: center;"><strong>Online Entry Form </strong> Address and phone information made available only to college coaches. If you have already registered and are trying to pay online, please click the Payment link above in the Fall League menu.</div></td> </tr> <tr> <td><strong>First Name*:</strong></td> <td colspan="3"><input maxlength="30" name="nameFirst" size="30" type="text" /></td> </tr> <tr> <td><strong>Last Name</strong>*:</td> <td colspan="3"><input maxlength="30" name="nameLast" size="30" type="text" /></td> </tr> <tr> <td><strong>Email*:</strong></td> <td colspan="3"><input maxlength="50" name="email" size="30" type="text" /></td> </tr> <tr> <td><strong>Address:</strong></td> <td colspan="3"><input maxlength="50" name="addressHome" size="30" type="text" /></td> </tr> <tr> <td><strong>State:</strong></td> <td colspan="3"><input maxlength="5" name="stateHome" size="2" type="text" /></td> </tr> <tr> <td><strong>Zip:</strong></td> <td colspan="3"><input maxlength="5" name="zipHome" size="6" type="text" /></td> </tr> <tr> <td><strong>Home Phone*:</strong></td> <td colspan="3"><input maxlength="13" name="phoneHome" size="13" type="text" /></td> </tr> <tr> <td><strong>Mobile Phone</strong>*:</td> <td colspan="3"><input maxlength="13" name="phoneMobile" size="13" type="text" /></td> </tr> <tr> <td><strong>High School*:</strong></td> <td colspan="3"><label></label> <input maxlength="30" name="school" size="30" type="text" /></td> </tr> <tr> <td><strong>Grade*:</strong></td> <td colspan="3"><input maxlength="2" name="grade" size="5" type="text" /></td> </tr> <tr> <td><strong>Varsity Coach*: </strong></td> <td colspan="3"><input maxlength="30" name="coachSchool" size="30" type="text" /></td> </tr> <tr> <td><strong>Feet*:</strong></td> <td width="10%"><input maxlength="1" name="feet" size="3" type="text" /></td> <td width="13%"><strong>Inches*:</strong></td> <td width="51%"><input maxlength="2" name="inches" size="3" type="text" /></td> </tr> <tr> <td></td> <td colspan="3"><input name="success" type="hidden" value="http://www.indybasketballevents.com/thankyou.php" /> * required</td> </tr> <tr> <td></td> <td colspan="3"></td> </tr> <tr> <td></td> <td colspan="3"><label for="Submit"></label> <input id="Submit" name="Submit" type="submit" value="Submit" /></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> </tr> </tbody></table> </form> -
Not sure how to even search for what I'm looking for, which is to say I'm really in need of guidance. I have a pre-populated database that I set up with about 260 names in it. It also has information like, height (basketball players) and high school. It's a list of kids I mean to invite to play in a league. From there, they will actually come to the league's site and register. I'd like for my form to check to see if they are already in the database, and if they are just add personal information, like email and phone number. If they are not, I'd like for the form to enter all of the information (name, school, etc).
-
I searched, but I rarely can make much of other people's problems when it comes to databases and PHP. Here is what I'm trying to do: I have a datatable full of names of basketball players. I have a datatable that is going to store links to videos to basketball players. Here is the query I have: $query = 'SELECT pr.*,v.* FROM (wp_playerRank) as pr, (hhr_video) as v WHERE pr.nameFirst = v.name_first AND pr.nameLast = v.name_last ORDER BY v.id_vid DESC'; $results = mysql_query($query); while($line = mysql_fetch_assoc($results)) There might be four or five video clips, as we start to compile this list over time. I want to echo information from the hhr_video table. I'm assuming with a FOREACH loop. Right?
-
It worked. I didn't refresh my table. Here is the correct syntax: UPDATE wp_usermeta SET meta_key = REPLACE (meta_key,'wp_1_','wp_')
-
Because that didn't work.
-
UPDATE wp_usermeta SET meta_key = REPLACE (meta_key,"wp_1_","wp_") UPDATE wp_usermeta SET meta_key = REPLACE ('meta_key',"wp_1_","wp_") Either of those?
-
Data inside the column. I'm trying to make values that start out with wp_1_ and have them just start wp_
-
Still not catching how it works, just because everywhere I look it says something different. Here is what I tried: UPDATE REPLACE ('meta_key', 'wp_1_', 'wp_')
-
The syntax is a little confusing. Am I using UPDATE, REPLACE or SELECT?
-
I have a number of values with wp_1_*rest of information*. I want to delete the "_1" from each of those values. Possible?
-
I need help linking information in different data tables...
Jim R replied to Jim R's topic in MySQL Help
Hmmm... Posts (post_tag) and images (ngg_tag) have the same term_id with post_tag and ngg_tag being their taxonomy. Tag Archive pages in WordPress usually print all Posts with the same term_id with the Taxonomy of post_tag. I'd like to also display images (Taxonomy => ngg_tag). To get from term_id to the image file name moves across three different data tables. -
I need help linking information in different data tables...
Jim R replied to Jim R's topic in MySQL Help
Let me provide a little direct insight into my database: I have a data table with images in it. ngg_pictures AS n. Each image has a 'pid', known as n.`pid`. Each 'pid' corroborates with an object_id in term_relationship AS tr. ....which carries with it a term_taxonomy_id. Each tr. term_taxonomy_id has an equal in term_taxonomy AS tt. ....tt.term_taxonomy_id also has a term_id within tt. tt.term_id has two terms, post_tag (WP tag) and ngg_tag (image tag). I'm trying to pull images that meet all of the criteria with WHERE AND statements. But from I can tell, it would just organize it internally. Nothing tells it which ones to pull. When clicking on a Tag Archive link, I do carry the tag_id, which is a standard WP query. The 'tag_id' is essentially the term_id. For another function on the Tag Archive page, I use this: $wp_tagID = get_query_var('tag_id'); That allows me to link that page to a custom data table where I have a player's information, such as school and in some cases contact information. I need to associate that with my image query too. -
This is primarily for WordPress, but I can't get anyone to help me, here (on another board) or elsewhere. When I click on a Tag on my blog, the user is taken to a Tag Archive page where any Post written tagged with that basketball player's name (most of my tags) shows up. That Tag carries with it a value, let's 68, for example, is the term_id, and it carries the label of post_tag. I'm also using a image plugin which lets me Tag images, and if it uses the same name, it gives it the same term_id but has the label of ngg_tag. So basically, when you go to the Tag Archive page, you have all the posts which carry that tag, as well as 8 random images (per the query below) that also carry that tag. Below is a MySQL query that links the images in ngg_pictures data table to my term_ids in another data table: $mf_query = <<<EOF SELECT t.*, tt.*, n.* FROM {$wpdb->term_relationships} as tr, {$wpdb->terms} AS t, {$wpdb->term_taxonomy} AS tt, {$wpdb->ngg_pictures} AS n WHERE tt.`taxonomy` = 'ngg_tag' AND tt.`term_id` = t.`term_id` AND tt.`term_taxonomy_id` = tr.`term_taxonomy_id` AND tr.`object_id` = n.`pid` ORDER BY rand() LIMIT 8 EOF; $mf_terms = $wpdb->get_results( $mf_query ); var_dump($mf_terms); echo ' <div id="gameCenter">'; foreach ( $mf_terms as $image ) { echo '<a href="' . $image->imageURL . '" title="' . $image->pid . '"' . $image->thumbcode . '>'; echo '<img title="' . $image->alttext . '" alt="' . $image->alttext . '" src="' . $image->thumbnailURL . '"' . $image->size . '/>'; } echo '</div>'; I put the var_dump in there because it wasn't working. All the var_dump produces is array(0) { } , which is to say it's not extracting anything. Here is a sample page: http://hoosierhoopsreport.com/tag/alexander-hutson/
-
I'm not getting much on this issue, which is frustrating. When you click on a Tag, it takes you to a Tag Archive page, and that Tag has a numeric value in the database. To access that Tag value I'm using: $wp_tagID = get_query_var('tag_id'); I already know this line works, because I have a file (plugin if you will) that inputs some of my own information onto the Tag Archive page. So for my example, the tag_id = 68, which has a taxonomy of 'post_tag'. Enter my problem. I'm using an image plugin, which allows me to Tag images, and it matches those Tags to the Tags already generated by WordPress. So it would have the tag_id = 68 but have the taxonomy of 'ngg_tag'. I want to take the images with the same Tags and put them on the Tag Archive page. My Tags are usually basketball player names, so clicking on his Tag takes you to a page with his profile information and every Post tagged with his name. I'd like to also have an assortment of pictures also appear on his page (Tag Archive). Here is the code I"m trying: // Picture Code echo '<div class="pictures">'; $mf_query = <<<EOF SELECT t.*, tt.*, p.*, n.* FROM {$wpdb->posts} as p, {$wpdb->term_relationships} as tr, {$wpdb->terms} AS t, {$wpdb->term_taxonomy} AS tt, {$wpdb->ngg_pictures} AS n WHERE tt.`taxonomy` = 'ngg_tag' AND tt.`term_id` = t.`term_id` AND tt.`term_taxonomy_id` = tr.`term_taxonomy_id` AND tr.`object_id` = n.`pid` ORDER BY rand() LIMIT 8 EOF; $mf_terms = $wpdb->get_results( $mf_query ); var_dump($mf_terms); if ($mf_terms [ 'term_id' ] == $wp_tagID) { echo ' <div id="gameCenter">'; foreach ( $mf_terms as $image ) { echo '<a href="' . $image->imageURL . '" title="' . $image->pid . '"' . $image->thumbcode . '>'; echo '<img title="' . $image->alttext . '" alt="' . $image->alttext . '" src="' . $image->thumbnailURL . '"' . $image->size . '/>'; } echo '</div>'; } // End picture code I'm not getting any errors, but in using the var_dump in there, I'm getting an array of 0. That tells me it's getting nothing from the database.
-
[WordPress]Having a problem echo'ing an href....
Jim R replied to Jim R's topic in Third Party Scripts
I literally just figured it out. I added get_ in front of the_permalink and the_title. This is kind of stuff that makes me thankful I don't code for a living. This took me a whole day, as it was producing the values I wanted, just not in hyperlink form. I tried another href statement, and it worked just fine. Not sure if it applies to my problem, but I read something in WordPress that the_title strips out the HTML attributes. Then it said something like See Also: get_the_title. I tried it. It worked. Thanks for looking at it though. I was a little worried it would be overlooked after it was moved. -
I linked the test page for the code below. It's producing the functional results I want, but the list bullets are askew and, as you will see, it's just printing the URL not producing a hyperlink. http://hoosierhoopsreport.com/test.php $mf_query = <<<EOF SELECT t.*, tt.*, p.* FROM {$wpdb->posts} as p, {$wpdb->term_relationships} as tr, {$wpdb->terms} AS t, {$wpdb->term_taxonomy} AS tt WHERE tt.`taxonomy` = 'series' AND t.`term_id` = tt.`term_id` AND tr.`object_id` = p.`ID` AND tt.`term_taxonomy_id` = tr.`term_taxonomy_id` AND tt.`count` > 0 GROUP BY t.`term_id` ORDER BY p.`post_date` DESC LIMIT 5 EOF; $mf_terms = $wpdb->get_results( $mf_query ); if( !empty( $mf_terms ) ) { foreach ( $mf_terms as $mf_term ) { $loop = new WP_Query( array( 'series' => $mf_term->slug ) ); if ( $loop->have_posts() ) : echo '<b>' . $mf_term->name . '</b>'; echo '<ul>'; while ( $loop->have_posts() ) : $loop->the_post(); echo '<li><a href="' . the_permalink() . '">' . the_title() . '</a></li>'; endwhile; wp_reset_query(); echo '</ul>'; endif; } }
-
I still need help with this.