I am trying to echo data out of a database, however, i am getting the following errors, even though all 3 variables have been.
Notice: Undefined variable: fran_phone in /Applications/MAMP/htdocs/PhpProject2/testing.php on line 58
For the following:
- Fran_phone
- Twit
- Fb
Code
mysqli_report(MYSQLI_REPORT_INDEX);
$dbc = new mysqli("localhost", "root", "root", "One_Delivery");
$dbc->set_charset("utf8mb4");
if (isset($_GET['area'])) {
$franc_details = $_GET['area'];
$get_franc_dets = "SELECT * FROM Franc_dets WHERE Fran_City = '$franc_details'";
$run_get_franc_dets = mysqli_query($dbc, $get_franc_dets);
mysqli_stmt_execute($run_get_franc_dets);
while ($row_get_franc_dets = mysqli_fetch_array($run_get_franc_dets)) {
$franc_phone = $row_get_franc_dets['Fran_Contact_Num'];
$twit = $row_get_franc_dets['Twitter'];
$fb = $row_get_franc_dets['Fb'];
}
}
?>
<div id='franc_div' >
<table id='franchise_dets'>
<tr id='frnc_tbl'>
<td class='collapse'>
<img src='./Images/franc_dets_phone.png' height='50' width='50' alt='Call us'>
</td>
<td class='phn_dets'>
<p id='phn_title'>Problems ordering?</p>
<p id='phn_numb'><?php echo $franc_phone ?></p>
</td>
<td class='collapse'>
<img src='./Images/franc_dets_twitter.png' height='50' width='50' alt='Twitter logo'>
</td>
<td class='twitter_dets'>
<p id='sm_title'>Social media</p>
<a id='sm_twit' href='https://twitter.com/<?php echo $twit ?>'>@<?php echo $twit ?></a>
</td>
<td class='collapse'>
<img src='./Images/franc_dets_fb.png' height='50' width='50' alt='Facebook logo' >
</td>
<td class='fb_dets'>
<a id='sm_fb' href='https://www.facebook.com/<?php echo $fb; ?>'><?php echo $fb; ?></a>
</td>
</tr>
</table>
</div>
where did i go wrong? what can i do to resolve it
fran_phonein your code. I see$franc_phone, butfran!=francif (isset($_GET['area'])) {so the first time into the page when the user has not yet entered anything they will of course be UNDEFINED