php - Grab a specific value from MySQL database -
php - Grab a specific value from MySQL database -
i'm trying value mysql database. need grab price particular item , here how table looks:
i'm not sure how go , thing think of grab cost table adding status query grabs results match domain_address
.
i test calling function <?php echo getpageurl();?>
returns http://vauxhallpartswarehouse.co.uk/
(which should match against database entry.
//table calls function <td bgcolor="#999999" align="center">price: <?php echo getprice();?></td> <?php function getprice() { $con=mysqli_connect("host","user","pass","db"); $price = mysqli_query($con, "select cost domains domain_address='<?php echo getpageurl();?>'"); mysqli_close($con); homecoming $price; //should 1 result returned since domain_address unique } ?>
this doesn't seem want work, , don't know how else grab price.
i know connetion fine , have code farther downwards script creates table results database, maybe code below?
<?php $con=mysqli_connect("host","user","pass","db")); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $results = mysqli_query($con, "select domain_name, domain_address, cost domains"); echo "<table border='1'> <tr><th>domain</th>.... </tr>"; while($row = mysqli_fetch_array($results)) { echo "<tr>"; echo "<td>" . $row['domain_name'] . "</td>"; echo "<td><a target='_blank' href=" . $row['domain_address'] . ">".... //etc mysqli_close($con); ?>
that's because in line:
$price = mysqli_query($con, "select cost domains domain_address='<?php echo getpageurl();?>'");
getpageurl()
not executed, it's static part of whole string. seek this:
$price = mysqli_query($con, "select cost domains domain_address='" . getpageurl() . "'");
php mysql
Comments
Post a Comment