Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,201,376 members, 7,978,197 topics. Date: Thursday, 17 October 2024 at 09:36 PM |
Nairaland Forum / Science/Technology / Programming / Hello Programmer Need Ur Assistance (1503 Views)
URGENT: Asp.net Programmer Need For A 3 Months Project In Abuja / Expirenced Developer/programmer Need For Paystack Payment Integration / Php Programmer Need Help (2) (3) (4)
Hello Programmer Need Ur Assistance by skyhighweb(m): 6:25am On Apr 18, 2017 |
hi i want to update two columns at once in auctions table one column hold the productname d other the productimage, have tried selecting each one at a time but not liking it, any assistance, thanks |
Re: Hello Programmer Need Ur Assistance by Donald3d(m): 9:01am On Apr 18, 2017 |
skyhighweb:mysql ? |
Re: Hello Programmer Need Ur Assistance by skyhighweb(m): 9:54am On Apr 18, 2017 |
Donald3d:yes |
Re: Hello Programmer Need Ur Assistance by ToyinDipo(m): 11:23am On Apr 18, 2017 |
update table set col1=val1, col2=val2 where ...... You should be able to find this on google though. |
Re: Hello Programmer Need Ur Assistance by skyhighweb(m): 11:26am On Apr 18, 2017 |
i retrieve data from here table name column data in it sports team_id 1 teams nike team_image nikeimmagelogo and place inside here table column data in it auctions team1 nike team1_image nikeimmagelogo plz note teams = team1 while team_image = team1_image and this the query i use to fill team1 // team1 $query = "SELECT team_id, team_image, teams FROM " . $DBPrefix . "sports"; $db->query($query, $params); $TPL_team1_list = '<select name="team1">' . "\n"; while ($row = $db->fetch()) { $selected = ($row['teams'] == $team1) ? 'selected="true"' : ''; $TPL_team1_list .= "\t" . '<option value="' . $row['teams'] . '" ' . $selected . '>' . $row['teams'] . '</option>' . "\n"; } $TPL_team1_list .= '</select>' . "\n"; and this the query i use to fill team1_image // team1_image $query = "SELECT team_id, team_image, teams FROM " . $DBPrefix . "sports"; $db->query($query, $params); $TPL_team1_image_list = '<select name="team1_image">' . "\n"; while ($row = $db->fetch()) { $selected = ($row['team_image'] == $team1_image) ? 'selected="true"' : ''; $TPL_team1_image_list .= "\t" . '<option value="' . $row['team_image'] . '" ' . $selected . '>' . $row['teams'] . '</option>' . "\n"; } $TPL_team1_image_list .= '</select>' . "\n"; i have to fill two form to manually insert both team1 and team1_image i need both query to be just one so when i select team1, team1_image automattically get attached and inserted hope u understand what am saying. |
Re: Hello Programmer Need Ur Assistance by cbrass(m): 7:24pm On Apr 18, 2017 |
Let me get home will help out |
Re: Hello Programmer Need Ur Assistance by skyhighweb(m): 8:57pm On Apr 18, 2017 |
cbrass:ok thanks |
Re: Hello Programmer Need Ur Assistance by cbrass(m): 8:14am On Apr 19, 2017 |
I slept off when I got home yesterday, I looked through your code but I don't see where you are doing the update |
Re: Hello Programmer Need Ur Assistance by cbrass(m): 9:50am On Apr 19, 2017 |
skyhighweb: wait i really need to know why you want to update the second table , the reason i asked is after going through your sql queries i cant find any WHERE CLAUSE so why do you really want to create two tables instead of a single table |
Re: Hello Programmer Need Ur Assistance by skyhighweb(m): 10:39am On Apr 19, 2017 |
cbrass:theres already two tables only one get updated with the name but its image doesnt get updated |
Re: Hello Programmer Need Ur Assistance by cbrass(m): 12:11pm On Apr 19, 2017 |
skyhighweb: OK you want the image column on the second table to update abi? |
Re: Hello Programmer Need Ur Assistance by skyhighweb(m): 12:15pm On Apr 19, 2017 |
cbrass:yes, the query only update one table at a time i want it to update two tables at a time |
Re: Hello Programmer Need Ur Assistance by cbrass(m): 2:02pm On Apr 19, 2017 |
skyhighweb: well i think this concept should work select from table source while loop { Update table 1 update table 2 } this will definitely work with the way your code is , only one table will be updated, follow the pattern i did and you are fine |
Re: Hello Programmer Need Ur Assistance by skyhighweb(m): 3:05pm On Apr 19, 2017 |
cbrass:can u include that for me in the code given? so i don't beat around d bush table1 is team1 table 2 is team1_image 1 Like |
Re: Hello Programmer Need Ur Assistance by webdeveloperqx: 3:10pm On Apr 19, 2017 |
cbrass solution will work for you , inside the while loop, do the second db query. 1 Like |
Re: Hello Programmer Need Ur Assistance by skyhighweb(m): 3:13pm On Apr 19, 2017 |
webdeveloperqx:plz from the code given above alter it for me thanks |
Re: Hello Programmer Need Ur Assistance by cbrass(m): 5:04pm On Apr 19, 2017 |
skyhighweb: ok brb |
Re: Hello Programmer Need Ur Assistance by cbrass(m): 5:12pm On Apr 19, 2017 |
skyhighweb: try this it should work , though i didn't test it , $query = "SELECT team_id, team_image, teams FROM " . $DBPrefix . "sports"; $db->query($query, $params); $TPL_team1_list = '<select name="team1">' . "\n"; while ($row = $db->fetch()) { $selected = ($row['teams'] == $team1) ? 'selected="true"' : ''; $TPL_team1_list .= "\t" . '<option value="' . $row['teams'] . '" ' . $selected . '>' . $row['teams'] . '</option>' . "\n"; $selected = ($row['team_image'] == $team1_image) ? 'selected="true"' : ''; $TPL_team1_image_list .= "\t" . '<option value="' . $row['team_image'] . '" ' . $selected . '>' . $row['teams'] . '</option>' . "\n"; } $TPL_team1_list .= '</select>' . "\n"; $TPL_team1_image_list .= '</select>' . "\n"; |
Re: Hello Programmer Need Ur Assistance by skyhighweb(m): 7:51pm On Apr 19, 2017 |
cbrass: didnt work almost the same with what i got |
Re: Hello Programmer Need Ur Assistance by cbrass(m): 7:55pm On Apr 19, 2017 |
skyhighweb: Wait Did u write this code your self before? and i also told you earlier that this code will not update your table in the db, |
Re: Hello Programmer Need Ur Assistance by skyhighweb(m): 9:02pm On Apr 19, 2017 |
cbrass:Yeah it update it only update one table at a time |
Re: Hello Programmer Need Ur Assistance by cbrass(m): 9:10pm On Apr 19, 2017 |
skyhighweb: If you wrote it your self then follow the example I gave you earlier, that will solve the issue you are having |
Re: Hello Programmer Need Ur Assistance by skyhighweb(m): 12:55pm On Apr 21, 2017 |
cbrass:ok have figure it out had to rewrite the codes again now working 1 Like |
(1) (Reply)
Basic Coding Experience, But Want To Create An App / Start Making Not Less Than 100k/month From Programming / See A Nigerian Who Is The Smartest Robotics Engineer In The World
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 28 |