Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,147,949 members, 7,799,227 topics. Date: Tuesday, 16 April 2024 at 05:16 PM

Connecting Two Tables N Display Similar Ids - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Connecting Two Tables N Display Similar Ids (884 Views)

Nairaland Uses Tables!! / How To Add Up Tables Using Php / Thread Closed. (2) (3) (4)

(1) (Reply) (Go Down)

Connecting Two Tables N Display Similar Ids by skyhighweb(m): 7:32pm On May 29, 2017
hi i have two tables
items and bids
items : columns: id car1 car2 4 toyota benz 6 camery lexus
bids columns auction bidder 4 james 4 tom 6 steve
i want items( id) to connect to bids (auction)
and display only it result.
Re: Connecting Two Tables N Display Similar Ids by badthinds: 9:14pm On May 29, 2017
skyhighweb:
hi i have two tables

items and bids

items :
columns:
id car1 car2
4 toyota benz
6 camery lexus

bids
columns
auction bidder
4 james
4 tom
6 steve

i want items( id) to connect to bids (auction)

and display only it result.
Your demand is not clear...but it seem clearer than your text. Again please (clearer this time)
Re: Connecting Two Tables N Display Similar Ids by Dekatron(m): 3:08am On May 30, 2017
skyhighweb:
hi i have two tables

items and bids

items :
columns:
id car1 car2
4 toyota benz
6 camery lexus

bids
columns
auction bidder
4 james
4 tom
6 steve

i want items( id) to connect to bids (auction)

and display only it result.

If I can understand you well, your tables do not have a mutual columns. . . .Quite rusty in sql. . .Clarify this, then we can continue
Re: Connecting Two Tables N Display Similar Ids by skyhighweb(m): 11:02am On May 30, 2017
ok here is what am trying to accomplish

hi thanks for replying, i have this code for menu which displays the right result

$query = "SELECT s.team_id, s.teams AS teams1, ss.team_id, ss.teams AS teams2, a.id, a.team1, a.team2 FROM " . $DBPrefix . "auctions a
LEFT JOIN " . $DBPrefix . "sports s ON (s.team_id = a.team1)
LEFT JOIN " . $DBPrefix . "sports ss ON (ss.team_id = a.team2)
WHERE a.id = :auc_id and a.id = a.id";
$params = array();
$params[] = array(':auc_id', $id, 'int');
$db->query($query, $params);
?>

<script type="text/javascript" src="js/dropdownjquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {

$("#menu"wink.change(function() {
$(this).after('<div id="loader"><img src="images/loading.gif" alt="loading subcategory" /></div>');
$.get('loadsubcat.php?menu=' + $(this).val(), function(data) {
$("#sub_cat"wink.html(data);
$('#loader').slideUp(200, function() {
$(this).remove();
});
});
});

});
</script>
<form name="bid">
<label for="category">Select Winner</label>
<select name="willwin" id="menu">

<?php
if ($db->numrows() > 0){
while ($row = $db->fetch()) { ?>
<option value=''></option>
<option value="<?php echo $row["team1"]; ?>"><?php echo $row["teams1"]; ?></option>
<option value="<?php echo $row["team2"]; ?>"><?php echo $row["teams2"]; ?></option>
<?php
}
}
?>
</select>
<br/><br/><br/>

<label>Tag Bettor</label>
<select name="sub_cat" id="sub_cat"></select>
</form>

now this is the SUBMENU code which also works but displays all the result in the willwin column instead of rows that are connected via AUCTIONS(id) and BIDS(auction) like in the menu code, ordinary this is suppose to do that.....b.auction = :auc_id... for the submenu but it doesnt work when i introduce it.

<?php
include('config.php');

$menu = $_GET['menu'];
$query = mysql_query("SELECT a.id, s.team_id, s.teams, u.nick, b.id, b.willwin, b.willlose, b.bidder FROM vs_bids b
LEFT JOIN " . $DBPrefix . "vs_users u ON (u.id = b.bidder)
LEFT JOIN " . $DBPrefix . "vs_auctions a ON (a.id = b.auction)
LEFT JOIN " . $DBPrefix . "vs_sports s ON (s.team_id = b.willwin)
WHERE willlose='$menu'"wink;

while($row = mysql_fetch_array($query)) {
echo "<option value=''></option>";
echo "<option value='$row[team_id]'>$row[nick]...$row[teams]</option>";
}
?>

i even have a pdo version and it has the same issue

<?php
include('dbconfig.php');
if($_POST['id'])
{
$id=$_POST['id'];

$stmt = $DB_con->prepare("SELECT a.id, s.team_id, s.teams, u.nick, b.id, b.willwin, b.willlose, b.bidder, b.auction FROM vs_bids b
LEFT JOIN " . $DBPrefix . "vs_users u ON (u.id = b.bidder)
LEFT JOIN " . $DBPrefix . "vs_auctions a ON (a.id = b.auction)
LEFT JOIN " . $DBPrefix . "vs_sports s ON (s.team_id = b.willwin)
WHERE willlose=:id"wink;

$stmt->bindParam(':id', $id);
$stmt->execute();
?><option selected="selected">Select State :</option><?php
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
?>
<option value="<?php echo $row['team_id']; ?>"><?php echo $row['nick']; ?> <?php echo $row['teams']; ?></option>
<?php
}
}
?>
same issue

any idea who to solve the issue

(1) (Reply)

An Interview With AI Sweigart And AI Klein / Football Trials In 3 European Countries / Ways To Make API Call In Javascript (webAPI)

(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. 23
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.