Jump to content

mby247

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mby247's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Pls I need help. I got two tables on a database but I dont know how to run them independently. Please find below our script. It is a shipping tracking website. All I want is each table to run independently once tracked. ------------------------------------------------- <?php //Connect To Database $hostname='localhost.com'; $username='forexample'; $password='xxxx'; $dbname='example'; $usertable='ECMY4572957'; mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.'); mysql_select_db($dbname); //This array contains all correct tracking numbers $track_number = $_POST['track_number']; if(empty($track_number)){ die('<b>Please go back & enter tracking number</b>'); } else if(strlen($track_number) <= 0 || strlen($track_number) > 15){ die('<b>Invalid tracking number, please go back</b>'); } else{ $correct_tracking_numbers=array(ECMY4572957, BHSZ006933); if(in_array($track_number,$correct_tracking_numbers)){ $query = 'SELECT * FROM ' . $usertable; $result = mysql_query($query) or die(mysql_error()); echo "<table border='5'> <tr> <th>Date/Time</th> <th>Event</th> <th>Location</th> <th>Details</th> <th>Type of Move</th> </tr>"; while($row = mysql_fetch_array($result)){ echo "<tr>"; echo "<td>" . $row['Date/Time'] . "</td>"; echo "<td>" . $row['Event'] . "</td>"; echo "<td>" . $row['Location'] . "</td>"; echo "<td>" . $row['Details'] . "</td>"; echo "<td>" . $row['Type of Move'] . "</td>"; echo "</tr>"; } echo "</table>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; }else{ echo '<b>The tracking number is invalid, Please go back & enter a Valid Tracking Number!</b>'; } } ?> </body> </html> How do I write or connect the second usertable to the php file as the first script which is working fine once tracked? The table name is "FTYX34555867". I don't know how to run or write multiple table on same database. All I need is, how to connect multiplt tables so each table can run different tracking number. Am stress as am not getting it well. Please help me.
  2. I want only the number assigned like in the $correct_tracking_number can run the query on Mysql cos even if I input wrong number or no input at all....mysql still run. I try using the key_exist() but it is not working. Pls help or advice on wat to do if I want a tracking number to run the query in mysql database.
  3. I do I remove my database info? Please advice cos there is no place for editing....? Actually am building a shipping firm website with track page. So the I want how to create tracking number so that it would run the record and table in mysql. Pls help.
  4. Hi member, am creating a shipping website with tracking page but I have problem with my php coding. I want only the tracking number entered into the tracking page to run MySql record on the database but with the code below, even any number i input or even with no input on the track page, would still run the database. Please I need help on...only the tracking number can run the record on MySQl. If my coding is wrong..pls correct me. ===================================================== <html> <body> <?php //Connect To Database $hostname='*********'; $username='*********'; $password='*********'; $dbname='**********'; $usertable='3456746my'; mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.'); mysql_select_db($dbname); //This array contains all correct tracking numbers $correct_tracking_numbers=array(22333); if(in_array(22333,$correct_tracking_numbers)){ $query = 'SELECT * FROM ' . $usertable; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo $row['Date/Time'] . " " . $row['Event']. " ". $row['Location']. " " . $row['Details'] . "<br/>"; } }else{ echo '<b>The tracking number you entered is not valid!</b>'; } ?> </body> </html> ================================================ Thanks all for reading and would appreciate a reply and help.
×
×
  • 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.