Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
02-11-2014, 11:13 AM #1
- Join Date
- May 2009
- Thanked 1 Time in 1 Post
Create new table for each unique id
Hi guys, have a problem I am struggling with. I have a database table which contains the fields
id - PK
alert_id - FK
letter - Char
number - int(11)
last_updated - Timestamp
Sql query to select the data is just a basic select
$sql = "SELECT * FROM `alert_availability`;
table 1 <---alert_id A B C <----letter 01:00am <--last_updated 3 2 5 <----number 02:00am 5 4 0 table 2 <---alert_id F T R <----letter 01:00<--last_updated 2 5 6 <----number ... ...
Any advice appreciated as always.
02-11-2014, 01:44 PM #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,662 Times in 2,631 Posts
You simply keep track of the last alert id and break the table whenever it changes. You need to ensure the query is sorted by the alert_id as well.
$lastid = null;
while ($row = $qry->fetch_assoc())
if ($lastid != $row['alert_id'])
if ($lastid != null)
$lastid = $row['alert_id'];
//. . .
Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)PHP Code:
header('HTTP/1.1 420 Enhance Your Calm');