Jump to content

How to show every single THANG ??


tommy168

Recommended Posts

Hay wut's happening forum?

 

so i am currently working on a mailing list and its function is to send EVERY single user a notification email once an entry they are looking for on a database is available

 

below is the mailing_list.php which sets up database connection and deals with the fields of the table:

 


<?php
include('view_function.php');
global $connect;
$connect = mysqli_connect("localhost", "", "") or die(mysqli_error($connect));
$error = mysqli_error($connect);
$db_select = mysqli_select_db($connect, "");

$select5 = "SELECT LS_CELL_TYPE FROM link_specificities
INNER JOIN links ON link_specificities.LS_LINK = links.L_ID
WHERE links.L_ID = $LinkID";
$get5 = mysqli_query($connect, $select5) or die(mysqli_error($connect));
while ($row5 = mysqli_fetch_array($get5)){

extract($row5);

$cellType = $row5['LS_CELL_TYPE'];

}

$select6 = "SELECT CT_NAME FROM cell_type WHERE CT_ID = '$cellType'";
$get6 = mysqli_query($connect, $select6) or die(mysqli_error($connect));

$i = 0;
while ($row6 = mysqli_fetch_array($get6)){

extract($row6);

$query[$i] = $row6['CT_NAME'];
$check = "select first_name, email from mailing_list WHERE query = '$query[$i]'";
$i++;
echo $query;
}
update($check);

?>

 

 

And below is the view_function.php that's included above:

 

 


<?php

function update($check){
global $query;
global $connect;
global $LinkID;

$result = mysqli_query($connect, $check) or die(mysqli_error($connect));

while ($row3 = mysqli_fetch_array($result)){

extract($row3);

$fname = $row3['first_name'];
$email = $row3['email'];

$to = "$fname <$email>";
$subject = "The query is updated.";
$headers = "From: asdfasdfasdf";
$body = "
Hello $fname,\r\n\nThis is to inform you that $query is updated, please go to this link to search for it:\r\n\nhttp:/asdfasdfasdfasdf/view/View.php?LinkID=$LinkID \r\n\nRegards,\r\n\";
if(send_email($to,$subject,$body,$headers)){
//there are no errors, return empty array
$errors = array();
} else {
$errors[] = "Server error, mail could not be sent.";
}

}
}
?>

 

 

As you can c in mailing_list.php, i echoed out $query, but it only echoed ONE result of that entire array

 

so wut i am trying to do is to make a while loop with a counter in it, but still only one result shows up

 

Basically, i want the $query to output all items in an array so that following SELECT statement can choose the item which matches the required query and send the users the notification email bout such particular query

 

How should i fix it in order to do just that?

 

Thx  :confused:

Link to comment
https://forums.phpfreaks.com/topic/228530-how-to-show-every-single-thang/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.