Hi all,
I am woring on a script where I need to do the following.
I run a MysQL query which returns a row of data.
$row_RoomAudit = mysql_fetch_assoc($RoomAudit);
Then using that data array I am using "in_array" to find out if each of the array elements contains a 1 (one).
$SeqData = array($row_RoomAudit['SeqID1301'],$row_RoomAudit['SeqID1302'],$row_RoomAudit['SeqID1303'],$row_RoomAudit['SeqID1304'],$row_RoomAudit['SeqID1305'],$row_RoomAudit['SeqID1306'],$row_RoomAudit['SeqID1307'],$row_RoomAudit['SeqID1308'],$row_RoomAudit['SeqID1309'],$row_RoomAudit['SeqID1310']);
and so on.......
At this point I then need to strip out the first 5 character from each of the array elements; which reduces the element name to:
1301,1302,1303,1304 and so no........
I then need to perform a MySQL query to lookup records from a table where the new (reduced element names) match a field in the table.
foreach ($row_RoomAudit as $key => $val) {
if (strpos($val, '1') !== FALSE && substr( $key, 0, 3)=='Seq' ){
mysql_select_db($database_rose, $link);
$query_QuestionLookup = sprintf("SELECT SeqHeader, SeqText FROM SequenceNo WHERE SeqID = '".$key."'");
$QuestionLookup = mysql_query($query_QuestionLookup, $link) or die(mysql_error());
$row_QuestionLookup = mysql_fetch_assoc($QuestionLookup);
$totalRows_QuestionLookup = mysql_num_rows($QuestionLookup);
$seq = $key;
}
}
I then need to output the returned rows.
At the moment the script returns the correct data but also the content of the "$row_RoomAudit" array.
SeqID1302 Vanity Basin - Taps Taps - Not Secure / Leaking - Repair
SeqID1302 SeqID1303 Vanity Basin - Taps Vanity Basin - Taps Taps - Not Secure / Leaking - Repair Pop Up Stoppers or Plug - Requires Adjusting
SeqID1302 SeqID1303 SeqID1304 Vanity Basin - Taps Vanity Basin - Taps Vanity Basin - Taps Taps - Not Secure / Leaking - Repair Pop Up Stoppers or Plug - Requires Adjusting Stained / Discoloured / Limescale Visible/ Tarnished - Repair
SeqID1302 SeqID1303 SeqID1304 SeqID1305 Vanity Basin - Taps Vanity Basin - Taps Vanity Basin - Taps Vanity Basin Taps - Not Secure / Leaking - Repair Pop Up Stoppers or Plug - Requires Adjusting Stained / Discoloured / Limescale Visible/ Tarnished - Repair Sink Cracked
SeqID1302 SeqID1303 SeqID1304 SeqID1305 SeqID1601 Vanity Basin - Taps Vanity Basin - Taps Vanity Basin - Taps Vanity Basin Toilet Taps - Not Secure / Leaking - Repair Pop Up Stoppers or Plug - Requires Adjusting Stained / Discoloured / Limescale Visible/ Tarnished - Repair Sink Cracked Bowl - Damaged/Cracked
SeqID1302 SeqID1303 SeqID1304 SeqID1305 SeqID1601 SeqID1602 Vanity Basin - Taps Vanity Basin - Taps Vanity Basin - Taps Vanity Basin Toilet Toilet Taps - Not Secure / Leaking - Repair Pop Up Stoppers or Plug - Requires Adjusting Stained / Discoloured / Limescale Visible/ Tarnished - Repair Sink Cracked Bowl - Damaged/Cracked Seat Loose or New Seat Needed - Repair/Replace
SeqID1302 SeqID1303 SeqID1304 SeqID1305 SeqID1601 SeqID1602 SeqID1603 Vanity Basin - Taps Vanity Basin - Taps Vanity Basin - Taps Vanity Basin Toilet Toilet Toilet Taps - Not Secure / Leaking - Repair Pop Up Stoppers or Plug - Requires Adjusting Stained / Discoloured / Limescale Visible/ Tarnished - Repair Sink Cracked Bowl - Damaged/Cracked Seat Loose or New Seat Needed - Repair/Replace Toilet Flush - Overflow Running/Handle Not Secure - Repair
SeqID1302 SeqID1303 SeqID1304 SeqID1305 SeqID1601 SeqID1602 SeqID1603 SeqID1604 Vanity Basin - Taps Vanity Basin - Taps Vanity Basin - Taps Vanity Basin Toilet Toilet Toilet Toilet Taps - Not Secure / Leaking - Repair Pop Up Stoppers or Plug - Requires Adjusting Stained / Discoloured / Limescale Visible/ Tarnished - Repair Sink Cracked Bowl - Damaged/Cracked Seat Loose or New Seat Needed - Repair/Replace Toilet Flush - Overflow Running/Handle Not Secure - Repair Limescale Visible
SeqID1302 SeqID1303 SeqID1304 SeqID1305 SeqID1601 SeqID1602 SeqID1603 SeqID1604 SeqID1605 Vanity Basin - Taps Vanity Basin - Taps Vanity Basin - Taps Vanity Basin Toilet Toilet Toilet Toilet Toilet Taps - Not Secure / Leaking - Repair Pop Up Stoppers or Plug - Requires Adjusting Stained / Discoloured / Limescale Visible/ Tarnished - Repair Sink Cracked Bowl - Damaged/Cracked Seat Loose or New Seat Needed - Repair/Replace Toilet Flush - Overflow Running/Handle Not Secure - Repair Limescale Visible Poor Grouting/Sealant/Strip - Repair
What I am look for is the returned data to look like:
SeqID1302 Vanity Basin - Taps - Not Secure / Leaking - Repair
SeqID1303 Vanity Basin - Pop Up Stoppers or Plug - Requires Adjusting
SeqID1304 Vanity Basin - Stained / Discoloured / Limescale Visible/ Tarnished - Repair
SeqID1305 Vanity Basin - Sink Cracked
SeqID1601 Toilet - Bowl - Damaged/Cracked
SeqID1602 Toilet - Seat Loose or New Seat Needed - Repair/Replace
SeqID1603 Toilet - Toilet Flush - Overflow Running/Handle Not Secure - Repair
SeqID1604 Toilet - Limescale Visible
SeqID1605 Toilet - Poor Grouting/Sealant/Strip - Repair
I know I am doing something wrong but after many attempts to get this working I failed.
Any help you can provide would be great. Many thanks in advance for your time.
Cheers.